diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-29 02:14:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 14:14:26 -0400 |
commit | a6450494c3a9c05667ae8a2ebdfdea55b8206e9b (patch) | |
tree | e4c6eba554eb4866337f82f2f96521b4b9370f84 /models/repo_transfer.go | |
parent | 572af214a7256fde76d0fa69fc5791b1758455ef (diff) | |
download | gitea-a6450494c3a9c05667ae8a2ebdfdea55b8206e9b.tar.gz gitea-a6450494c3a9c05667ae8a2ebdfdea55b8206e9b.zip |
Fix unclear `IsRepositoryExist` logic (#24374)
There was only one `IsRepositoryExist` function, it did: `has && isDir`
However it's not right, and it would cause 500 error when creating a new
repository if the dir exists.
Then, it was changed to `has || isDir`, it is still incorrect, it
affects the "adopt repo" logic.
To make the logic clear:
* IsRepositoryModelOrDirExist
* IsRepositoryModelExist
Diffstat (limited to 'models/repo_transfer.go')
-rw-r--r-- | models/repo_transfer.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/models/repo_transfer.go b/models/repo_transfer.go index 27a77f9b8c..1c873cec57 100644 --- a/models/repo_transfer.go +++ b/models/repo_transfer.go @@ -172,7 +172,7 @@ func CreatePendingRepositoryTransfer(ctx context.Context, doer, newOwner *user_m } // Check if new owner has repository with same name. - if has, err := repo_model.IsRepositoryExist(ctx, newOwner, repo.Name); err != nil { + if has, err := repo_model.IsRepositoryModelExist(ctx, newOwner, repo.Name); err != nil { return fmt.Errorf("IsRepositoryExist: %w", err) } else if has { return repo_model.ErrRepoAlreadyExist{ @@ -249,7 +249,7 @@ func TransferOwnership(doer *user_model.User, newOwnerName string, repo *repo_mo newOwnerName = newOwner.Name // ensure capitalisation matches // Check if new owner has repository with same name. - if has, err := repo_model.IsRepositoryExist(ctx, newOwner, repo.Name); err != nil { + if has, err := repo_model.IsRepositoryModelOrDirExist(ctx, newOwner, repo.Name); err != nil { return fmt.Errorf("IsRepositoryExist: %w", err) } else if has { return repo_model.ErrRepoAlreadyExist{ |