diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 88cbd701d2..36099896bf 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -421,7 +421,7 @@ func Download(ctx *context.Context) { if err != nil { if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) { ctx.Error(http.StatusBadRequest, err.Error()) - } else if errors.Is(err, archiver_service.RepoRefNotFoundError{}) { + } else if errors.Is(err, archiver_service.RepoRefNotFoundError{}) || git.IsErrNotExist(err) { ctx.Error(http.StatusNotFound, err.Error()) } else { ctx.ServerError("archiver_service.NewRequest", err) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 2ac1632188..5d3908eb7e 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -720,3 +720,12 @@ func TestRenamedFileHistory(t *testing.T) { htmlDoc.AssertElement(t, ".ui.bottom.attached.header", false) }) } + +func TestArchiveRequest(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + session := loginUser(t, "user2") + + req := NewRequest(t, "GET", "/user2/repo1/archive/a480fe666d6f550787b6cc85047b966d1f8d6bbf.zip") + session.MakeRequest(t, req, http.StatusNotFound) +}