Skip to content

Commit 9f28335

Browse files
zeripathlunny
andcommitted
Ensure that git repository is closed before transfer (go-gitea#18049)
Backport go-gitea#18049 Repository Transfer requires that the repository directory is renamed - which is not possible on Windows if the git repository is open. Fix go-gitea#17885 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 9086916 commit 9f28335

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

routers/api/v1/repo/transfer.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ func Transfer(ctx *context.APIContext) {
9696
}
9797
}
9898

99+
if ctx.Repo.GitRepo != nil {
100+
ctx.Repo.GitRepo.Close()
101+
ctx.Repo.GitRepo = nil
102+
}
103+
99104
if err := repo_service.StartRepositoryTransfer(ctx.User, newOwner, ctx.Repo.Repository, teams); err != nil {
100105
if models.IsErrRepoTransferInProgress(err) {
101106
ctx.Error(http.StatusConflict, "CreatePendingRepositoryTransfer", err)

routers/web/repo/repo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
319319
}
320320

321321
if accept {
322+
if ctx.Repo.GitRepo != nil {
323+
ctx.Repo.GitRepo.Close()
324+
ctx.Repo.GitRepo = nil
325+
}
326+
322327
if err := repo_service.TransferOwnership(repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams); err != nil {
323328
return err
324329
}

0 commit comments

Comments
 (0)