Skip to content

Commit d3888f8

Browse files
committed
When the git repository on storage is changed, the repository modal should also be updated.
1 parent 7cc4449 commit d3888f8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

routers/web/repo/view.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,25 @@ func renderCode(ctx *context.Context) {
840840
ctx.Data["PageIsViewCode"] = true
841841

842842
if ctx.Repo.Repository.IsEmpty {
843-
ctx.HTML(http.StatusOK, tplRepoEMPTY)
844-
return
843+
reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
844+
if err != nil {
845+
ctx.ServerError("GitRepo.IsEmpty", err)
846+
return
847+
}
848+
if reallyEmpty {
849+
ctx.HTML(http.StatusOK, tplRepoEMPTY)
850+
return
851+
}
852+
// the repo is not really empty, so we should update the modal in database
853+
ctx.Repo.Repository.IsEmpty = false
854+
if err = repo_model.UpdateRepositoryCols(ctx.Repo.Repository, "is_empty"); err != nil {
855+
ctx.ServerError("UpdateRepositoryCols", err)
856+
return
857+
}
858+
if err = models.UpdateRepoSize(db.DefaultContext, ctx.Repo.Repository); err != nil {
859+
ctx.ServerError("UpdateRepoSize", err)
860+
return
861+
}
845862
}
846863

847864
title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name

0 commit comments

Comments
 (0)