diff options
author | zeripath <art27@cantab.net> | 2021-12-21 02:01:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-21 10:01:58 +0800 |
commit | bef93abd499e7d9d6b63741ecd6b0cd3ab601cf8 (patch) | |
tree | 19da177afc0a5599ddb4816a2fe156c1448d79f3 | |
parent | be91df42d1195fed3ecc39a714448bcec0bb1cce (diff) | |
download | gitea-bef93abd499e7d9d6b63741ecd6b0cd3ab601cf8.tar.gz gitea-bef93abd499e7d9d6b63741ecd6b0cd3ab601cf8.zip |
Ensure that git repository is closed before transfer (#18049)
Repository Transfer requires that the repository directory is renamed - which
is not possible on Windows if the git repository is open.
Fix #17885
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | routers/api/v1/repo/transfer.go | 5 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go index abaed4d587..dd7730b42c 100644 --- a/routers/api/v1/repo/transfer.go +++ b/routers/api/v1/repo/transfer.go @@ -98,6 +98,11 @@ func Transfer(ctx *context.APIContext) { } } + if ctx.Repo.GitRepo != nil { + ctx.Repo.GitRepo.Close() + ctx.Repo.GitRepo = nil + } + if err := repo_service.StartRepositoryTransfer(ctx.User, newOwner, ctx.Repo.Repository, teams); err != nil { if models.IsErrRepoTransferInProgress(err) { ctx.Error(http.StatusConflict, "CreatePendingRepositoryTransfer", err) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index a1e652f94c..9a36e6ee1d 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -323,6 +323,11 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error { } if accept { + if ctx.Repo.GitRepo != nil { + ctx.Repo.GitRepo.Close() + ctx.Repo.GitRepo = nil + } + if err := repo_service.TransferOwnership(repoTransfer.Doer, repoTransfer.Recipient, ctx.Repo.Repository, repoTransfer.Teams); err != nil { return err } |