Correctly check whether parent directory is writable for current user.

"&04" was checking if file is readable by others, while "&0200" checks
if it's writable for current user.

(Fixes #904)
This commit is contained in:
Vilbrekin
2014-10-26 01:54:50 +02:00
parent d8b335ce65
commit 970e50d1f1
5 changed files with 31 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ func Rename(from, to string) error {
// containing `path` is writable for the duration of the call.
func InWritableDir(fn func(string) error, path string) error {
dir := filepath.Dir(path)
if info, err := os.Stat(dir); err == nil && info.IsDir() && info.Mode()&04 == 0 {
if info, err := os.Stat(dir); err == nil && info.IsDir() && info.Mode()&0200 == 0 {
// A non-writeable directory (for this user; we assume that's the
// relevant part). Temporarily change the mode so we can delete the
// file or directory inside it.