pass repo to cleanupRepository and remove the loading

This commit is contained in:
silverwind
2026-02-01 08:59:33 +01:00
parent e94ea1b961
commit 5c75e4a94d
3 changed files with 6 additions and 12 deletions
+4 -10
View File
@@ -266,7 +266,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
defer func() {
if err != nil {
// we can not use the ctx because it maybe canceled or timeout
cleanupRepository(repo.ID)
cleanupRepository(repo)
}
}()
@@ -461,17 +461,11 @@ func createRepositoryInDB(ctx context.Context, doer, u *user_model.User, repo *r
return nil
}
func cleanupRepository(repoID int64) {
func cleanupRepository(repo *repo_model.Repository) {
ctx := graceful.GetManager().ShutdownContext()
if errDelete := DeleteRepositoryDirectly(ctx, repoID); errDelete != nil {
if errDelete := DeleteRepositoryDirectly(ctx, repo.ID); errDelete != nil {
log.Error("cleanupRepository failed: %v", errDelete)
// Try to get repository name for better error message
repoIdentifier := fmt.Sprintf("[%d]", repoID)
if repo, err := repo_model.GetRepositoryByID(ctx, repoID); err == nil {
repoIdentifier = fmt.Sprintf("(%s)", repo.FullName())
}
// add system notice
if err := system_model.CreateRepositoryNotice("DeleteRepositoryDirectly failed when cleanup repository %s: %v", repoIdentifier, errDelete); err != nil {
if err := system_model.CreateRepositoryNotice("DeleteRepositoryDirectly failed when cleanup repository (%s)", repo.FullName(), errDelete); err != nil {
log.Error("CreateRepositoryNotice: %v", err)
}
}
+1 -1
View File
@@ -124,7 +124,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
defer func() {
if err != nil {
// we can not use the ctx because it maybe canceled or timeout
cleanupRepository(repo.ID)
cleanupRepository(repo)
}
}()
+1 -1
View File
@@ -101,7 +101,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ
defer func() {
if err != nil {
// we can not use the ctx because it maybe canceled or timeout
cleanupRepository(generateRepo.ID)
cleanupRepository(generateRepo)
}
}()