Sfoglia il codice sorgente

Fix race condition in repo renaming (#3418)

tags/v1.4.0-rc1
Ethan Koenig 6 anni fa
parent
commit
bac6ac033a
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6
    1
      models/repo.go

+ 6
- 1
models/repo.go Vedi File

@@ -1579,7 +1579,12 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
return fmt.Errorf("GetRepositoryByName: %v", err)
}

// Change repository directory name.
// Change repository directory name. We must lock the local copy of the
// repo so that we can atomically rename the repo path and updates the
// local copy's origin accordingly.
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))

newRepoPath := RepoPath(u.Name, newRepoName)
if err = os.Rename(repo.RepoPath(), newRepoPath); err != nil {
return fmt.Errorf("rename repository directory: %v", err)

Loading…
Annulla
Salva