aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/migrations/gitea_uploader.go1
-rw-r--r--routers/admin/repos.go4
-rw-r--r--routers/api/v1/repo/repo.go4
-rw-r--r--routers/repo/setting.go5
4 files changed, 14 insertions, 0 deletions
diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go
index bd6084d6a1..29118fd51b 100644
--- a/modules/migrations/gitea_uploader.go
+++ b/modules/migrations/gitea_uploader.go
@@ -851,6 +851,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
// Rollback when migrating failed, this will rollback all the changes.
func (g *GiteaLocalUploader) Rollback() error {
if g.repo != nil && g.repo.ID > 0 {
+ g.gitRepo.Close()
if err := models.DeleteRepository(g.doer, g.repo.OwnerID, g.repo.ID); err != nil {
return err
}
diff --git a/routers/admin/repos.go b/routers/admin/repos.go
index 82b8cc1a7d..d23f7c3d5a 100644
--- a/routers/admin/repos.go
+++ b/routers/admin/repos.go
@@ -47,6 +47,10 @@ func DeleteRepo(ctx *context.Context) {
return
}
+ if ctx.Repo != nil && ctx.Repo.GitRepo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == repo.ID {
+ ctx.Repo.GitRepo.Close()
+ }
+
if err := repo_service.DeleteRepository(ctx.User, repo); err != nil {
ctx.ServerError("DeleteRepository", err)
return
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index d8600c0fcd..7a3160fa99 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -889,6 +889,10 @@ func Delete(ctx *context.APIContext) {
return
}
+ if ctx.Repo.GitRepo != nil {
+ ctx.Repo.GitRepo.Close()
+ }
+
if err := repo_service.DeleteRepository(ctx.User, repo); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteRepository", err)
return
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index b37ac03112..51bf68b15b 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -544,6 +544,11 @@ func SettingsPost(ctx *context.Context) {
return
}
+ // Close the gitrepository before doing this.
+ if ctx.Repo.GitRepo != nil {
+ ctx.Repo.GitRepo.Close()
+ }
+
if err := repo_service.DeleteRepository(ctx.User, ctx.Repo.Repository); err != nil {
ctx.ServerError("DeleteRepository", err)
return