mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Add abstraction layer to check if the repository exists on disk (#33874)
Extract from #28966 This PR uses `gitrepo.IsRepositoryExist` instead of `util.IsExist` to detect whether the repository exist in disk. This will move `RepoPath` detail behind of package `gitrepo` to make it easier to do possible changes where storing the repositories. No code change
This commit is contained in:
@@ -110,15 +110,13 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
|
||||
return
|
||||
}
|
||||
|
||||
repoPath := repo_model.RepoPath(owner.Name, repo.Name)
|
||||
|
||||
if exists, _ := util.IsExist(repoPath); !exists {
|
||||
if exists, _ := gitrepo.IsRepositoryExist(ctx, repo); !exists {
|
||||
return
|
||||
}
|
||||
|
||||
// As the transaction will be failed and hence database changes will be destroyed we only need
|
||||
// to delete the related repository on the filesystem
|
||||
if errDelete := util.RemoveAll(repoPath); errDelete != nil {
|
||||
if errDelete := util.RemoveAll(repo.RepoPath()); errDelete != nil {
|
||||
log.Error("Failed to remove fork repo")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user