summaryrefslogtreecommitdiffstats
path: root/modules/repository/repo.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-06 16:01:49 +0800
committerGitHub <noreply@github.com>2022-06-06 16:01:49 +0800
commit26095115f4ae90e3fdc6ab695978efd16e317f75 (patch)
tree92ec1c7ff54e0a65f4f0662baa8c0244dd9f324b /modules/repository/repo.go
parentebeb6e7c71a0c763b52153f4eb427e7c5b89a95e (diff)
downloadgitea-26095115f4ae90e3fdc6ab695978efd16e317f75.tar.gz
gitea-26095115f4ae90e3fdc6ab695978efd16e317f75.zip
Move some repository related code into sub package (#19711)
* Move some repository related code into sub package * Move more repository functions out of models * Fix lint * Some performance optimization for webhooks and others * some refactors * Fix lint * Fix * Update modules/repository/delete.go Co-authored-by: delvh <dev.lh@web.de> * Fix test * Merge * Fix test * Fix test * Fix test * Fix test Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'modules/repository/repo.go')
-rw-r--r--modules/repository/repo.go25
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 30ca6fdff8..281999a1eb 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -116,7 +116,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
repo.Owner = u
}
- if err = models.CheckDaemonExportOK(ctx, repo); err != nil {
+ if err = CheckDaemonExportOK(ctx, repo); err != nil {
return repo, fmt.Errorf("checkDaemonExportOK: %v", err)
}
@@ -168,9 +168,11 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
}
}
- if err = models.UpdateRepoSize(ctx, repo); err != nil {
- log.Error("Failed to update size for repository: %v", err)
+ ctx, committer, err := db.TxContext()
+ if err != nil {
+ return nil, err
}
+ defer committer.Close()
if opts.Mirror {
mirrorModel := repo_model.Mirror{
@@ -203,17 +205,24 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
}
}
- if err = repo_model.InsertMirror(&mirrorModel); err != nil {
+ if err = repo_model.InsertMirror(ctx, &mirrorModel); err != nil {
return repo, fmt.Errorf("InsertOne: %v", err)
}
repo.IsMirror = true
- err = models.UpdateRepository(repo, false)
+ if err = UpdateRepository(ctx, repo, false); err != nil {
+ return nil, err
+ }
} else {
- repo, err = CleanUpMigrateInfo(ctx, repo)
+ if err = UpdateRepoSize(ctx, repo); err != nil {
+ log.Error("Failed to update size for repository: %v", err)
+ }
+ if repo, err = CleanUpMigrateInfo(ctx, repo); err != nil {
+ return nil, err
+ }
}
- return repo, err
+ return repo, committer.Commit()
}
// cleanUpMigrateGitConfig removes mirror info which prevents "push --all".
@@ -253,7 +262,7 @@ func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo
}
}
- return repo, models.UpdateRepository(repo, false)
+ return repo, UpdateRepository(ctx, repo, false)
}
// SyncReleasesWithTags synchronizes release table with repository tags