mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-11 09:15:31 +02:00
pass repo to cleanupRepository and remove the loading
This commit is contained in:
parent
e94ea1b961
commit
5c75e4a94d
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user