diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 4 | ||||
-rw-r--r-- | models/repo_transfer.go | 8 | ||||
-rw-r--r-- | models/ssh_key.go | 4 | ||||
-rw-r--r-- | models/user.go | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/models/repo.go b/models/repo.go index 143dff9ac3..d6abc1b5e3 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1227,7 +1227,7 @@ func ChangeRepositoryName(doer *User, repo *Repository, newRepoName string) (err } newRepoPath := RepoPath(repo.Owner.Name, newRepoName) - if err = os.Rename(repo.RepoPath(), newRepoPath); err != nil { + if err = util.Rename(repo.RepoPath(), newRepoPath); err != nil { return fmt.Errorf("rename repository directory: %v", err) } @@ -1238,7 +1238,7 @@ func ChangeRepositoryName(doer *User, repo *Repository, newRepoName string) (err return err } if isExist { - if err = os.Rename(wikiPath, WikiPath(repo.Owner.Name, newRepoName)); err != nil { + if err = util.Rename(wikiPath, WikiPath(repo.Owner.Name, newRepoName)); err != nil { return fmt.Errorf("rename repository wiki: %v", err) } } diff --git a/models/repo_transfer.go b/models/repo_transfer.go index c5d1a3a3c2..d7ef0a8ca6 100644 --- a/models/repo_transfer.go +++ b/models/repo_transfer.go @@ -210,13 +210,13 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e } if repoRenamed { - if err := os.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil { + if err := util.Rename(RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name)); err != nil { log.Critical("Unable to move repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, RepoPath(newOwnerName, repo.Name), RepoPath(oldOwnerName, repo.Name), err) } } if wikiRenamed { - if err := os.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil { + if err := util.Rename(WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name)); err != nil { log.Critical("Unable to move wiki for repository %s/%s directory from %s back to correct place %s: %v", oldOwnerName, repo.Name, WikiPath(newOwnerName, repo.Name), WikiPath(oldOwnerName, repo.Name), err) } } @@ -358,7 +358,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e return fmt.Errorf("Failed to create dir %s: %v", dir, err) } - if err := os.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil { + if err := util.Rename(RepoPath(oldOwner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil { return fmt.Errorf("rename repository directory: %v", err) } repoRenamed = true @@ -370,7 +370,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e log.Error("Unable to check if %s exists. Error: %v", wikiPath, err) return err } else if isExist { - if err := os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil { + if err := util.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil { return fmt.Errorf("rename repository wiki: %v", err) } wikiRenamed = true diff --git a/models/ssh_key.go b/models/ssh_key.go index e35fc12e08..12c7bc9116 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -842,7 +842,7 @@ func rewriteAllPublicKeys(e Engine) error { } t.Close() - return os.Rename(tmpPath, fPath) + return util.Rename(tmpPath, fPath) } // RegeneratePublicKeys regenerates the authorized_keys file @@ -1324,7 +1324,7 @@ func rewriteAllPrincipalKeys(e Engine) error { } t.Close() - return os.Rename(tmpPath, fPath) + return util.Rename(tmpPath, fPath) } // ListPrincipalKeys returns a list of principals belongs to given user. diff --git a/models/user.go b/models/user.go index 3b8ce79251..f606da53d6 100644 --- a/models/user.go +++ b/models/user.go @@ -1027,7 +1027,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } // Do not fail if directory does not exist - if err = os.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) { + if err = util.Rename(UserPath(oldUserName), UserPath(newUserName)); err != nil && !os.IsNotExist(err) { return fmt.Errorf("Rename user directory: %v", err) } @@ -1036,7 +1036,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } if err = sess.Commit(); err != nil { - if err2 := os.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) { + if err2 := util.Rename(UserPath(newUserName), UserPath(oldUserName)); err2 != nil && !os.IsNotExist(err2) { log.Critical("Unable to rollback directory change during failed username change from: %s to: %s. DB Error: %v. Filesystem Error: %v", oldUserName, newUserName, err, err2) return fmt.Errorf("failed to rollback directory change during failed username change from: %s to: %s. DB Error: %w. Filesystem Error: %v", oldUserName, newUserName, err, err2) } |