summaryrefslogtreecommitdiffstats
path: root/modules/repository/repo.go
diff options
context:
space:
mode:
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