mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
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
This commit is contained in:
parent
572af214a7
commit
a6450494c3
8 changed files with 20 additions and 16 deletions
|
@ -116,7 +116,7 @@ func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdo
|
|||
return err
|
||||
}
|
||||
|
||||
has, err := IsRepositoryExist(db.DefaultContext, u, name)
|
||||
has, err := IsRepositoryModelOrDirExist(db.DefaultContext, u, name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("IsRepositoryExist: %w", err)
|
||||
} else if has {
|
||||
|
@ -147,7 +147,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
|
|||
return err
|
||||
}
|
||||
|
||||
has, err := IsRepositoryExist(db.DefaultContext, repo.Owner, newRepoName)
|
||||
has, err := IsRepositoryModelOrDirExist(db.DefaultContext, repo.Owner, newRepoName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("IsRepositoryExist: %w", err)
|
||||
} else if has {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue