Don't unnecessarily chmod directories when renaming

This commit is contained in:
Jakob Borg 2015-01-06 22:10:44 +01:00
parent 010d5a0192
commit 9a50c4d93f

View File

@ -43,8 +43,8 @@ func Rename(from, to string) error {
// Make sure the destination directory is writeable
toDir := filepath.Dir(to)
if info, err := os.Stat(toDir); err == nil {
os.Chmod(toDir, 0777)
if info, err := os.Stat(toDir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
os.Chmod(toDir, 0755)
defer os.Chmod(toDir, info.Mode())
}