mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	| @@ -346,7 +346,7 @@ func DeleteOldRepositoryArchives(ctx context.Context, olderThan time.Duration) e | ||||
| 	log.Trace("Doing: ArchiveCleanup") | ||||
|  | ||||
| 	for { | ||||
| 		archivers, err := repo_model.FindRepoArchives(repo_model.FindRepoArchiversOption{ | ||||
| 		archivers, err := repo_model.FindRepoArchives(ctx, repo_model.FindRepoArchiversOption{ | ||||
| 			ListOptions: db.ListOptions{ | ||||
| 				PageSize: 100, | ||||
| 				Page:     1, | ||||
| @@ -374,7 +374,7 @@ func DeleteOldRepositoryArchives(ctx context.Context, olderThan time.Duration) e | ||||
|  | ||||
| // DeleteRepositoryArchives deletes all repositories' archives. | ||||
| func DeleteRepositoryArchives(ctx context.Context) error { | ||||
| 	if err := repo_model.DeleteAllRepoArchives(); err != nil { | ||||
| 	if err := repo_model.DeleteAllRepoArchives(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return storage.Clean(storage.RepoArchives) | ||||
|   | ||||
| @@ -5,6 +5,8 @@ | ||||
| package repository | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"code.gitea.io/gitea/models" | ||||
| 	"code.gitea.io/gitea/models/db" | ||||
| 	access_model "code.gitea.io/gitea/models/perm/access" | ||||
| @@ -12,13 +14,13 @@ import ( | ||||
| ) | ||||
|  | ||||
| // DeleteCollaboration removes collaboration relation between the user and repository. | ||||
| func DeleteCollaboration(repo *repo_model.Repository, uid int64) (err error) { | ||||
| func DeleteCollaboration(ctx context.Context, repo *repo_model.Repository, uid int64) (err error) { | ||||
| 	collaboration := &repo_model.Collaboration{ | ||||
| 		RepoID: repo.ID, | ||||
| 		UserID: uid, | ||||
| 	} | ||||
|  | ||||
| 	ctx, committer, err := db.TxContext(db.DefaultContext) | ||||
| 	ctx, committer, err := db.TxContext(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -18,10 +18,10 @@ func TestRepository_DeleteCollaboration(t *testing.T) { | ||||
|  | ||||
| 	repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4}) | ||||
| 	assert.NoError(t, repo.LoadOwner(db.DefaultContext)) | ||||
| 	assert.NoError(t, DeleteCollaboration(repo, 4)) | ||||
| 	assert.NoError(t, DeleteCollaboration(db.DefaultContext, repo, 4)) | ||||
| 	unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4}) | ||||
|  | ||||
| 	assert.NoError(t, DeleteCollaboration(repo, 4)) | ||||
| 	assert.NoError(t, DeleteCollaboration(db.DefaultContext, repo, 4)) | ||||
| 	unittest.AssertNotExistsBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4}) | ||||
|  | ||||
| 	unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: repo.ID}) | ||||
|   | ||||
| @@ -292,7 +292,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { | ||||
| 	} | ||||
|  | ||||
| 	// Change repository last updated time. | ||||
| 	if err := repo_model.UpdateRepositoryUpdatedTime(repo.ID, time.Now()); err != nil { | ||||
| 	if err := repo_model.UpdateRepositoryUpdatedTime(ctx, repo.ID, time.Now()); err != nil { | ||||
| 		return fmt.Errorf("UpdateRepositoryUpdatedTime: %w", err) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -95,12 +95,12 @@ func PushCreateRepo(ctx context.Context, authUser, owner *user_model.User, repoN | ||||
| } | ||||
|  | ||||
| // Init start repository service | ||||
| func Init() error { | ||||
| func Init(ctx context.Context) error { | ||||
| 	if err := repo_module.LoadRepoConfig(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	system_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repository uploads", setting.Repository.Upload.TempPath) | ||||
| 	system_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repositories", repo_module.LocalCopyPath()) | ||||
| 	system_model.RemoveAllWithNotice(ctx, "Clean up temporary repository uploads", setting.Repository.Upload.TempPath) | ||||
| 	system_model.RemoveAllWithNotice(ctx, "Clean up temporary repositories", repo_module.LocalCopyPath()) | ||||
| 	if err := initPushQueue(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
| @@ -37,7 +37,7 @@ func TransferOwnership(ctx context.Context, doer, newOwner *user_model.User, rep | ||||
| 	oldOwner := repo.Owner | ||||
|  | ||||
| 	repoWorkingPool.CheckIn(fmt.Sprint(repo.ID)) | ||||
| 	if err := models.TransferOwnership(doer, newOwner.Name, repo); err != nil { | ||||
| 	if err := models.TransferOwnership(ctx, doer, newOwner.Name, repo); err != nil { | ||||
| 		repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) | ||||
| 		return err | ||||
| 	} | ||||
| @@ -70,7 +70,7 @@ func ChangeRepositoryName(ctx context.Context, doer *user_model.User, repo *repo | ||||
| 	// local copy's origin accordingly. | ||||
|  | ||||
| 	repoWorkingPool.CheckIn(fmt.Sprint(repo.ID)) | ||||
| 	if err := repo_model.ChangeRepositoryName(doer, repo, newRepoName); err != nil { | ||||
| 	if err := repo_model.ChangeRepositoryName(ctx, doer, repo, newRepoName); err != nil { | ||||
| 		repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user