diff --git a/cmd/object-common.go b/cmd/object-common.go index 41ee43027..35d98e912 100644 --- a/cmd/object-common.go +++ b/cmd/object-common.go @@ -224,8 +224,7 @@ func cleanupDir(storage StorageAPI, volume, dirPath string) error { delFunc = func(entryPath string) error { if !strings.HasSuffix(entryPath, slashSeparator) { // Delete the file entry. - err := storage.DeleteFile(volume, entryPath) - return traceError(err) + return traceError(storage.DeleteFile(volume, entryPath)) } // If it's a directory, list and call delFunc() for each entry. diff --git a/cmd/posix.go b/cmd/posix.go index 275ea40d1..b30bfa101 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -694,6 +694,11 @@ func deleteFile(basePath, deletePath string) error { } // Attempt to remove path. if err := os.Remove(preparePath(deletePath)); err != nil { + if os.IsNotExist(err) { + return errFileNotFound + } else if os.IsPermission(err) { + return errFileAccessDenied + } return err } // Recursively go down the next path and delete again. diff --git a/cmd/posix_test.go b/cmd/posix_test.go index 6bccb66cb..200ee8674 100644 --- a/cmd/posix_test.go +++ b/cmd/posix_test.go @@ -678,8 +678,8 @@ func TestPosixListDir(t *testing.T) { t.Errorf("Unable to initialize posix, %s", err) } - if err = posixStorage.DeleteFile("bin", "yes"); !os.IsPermission(err) { - t.Errorf("expected: Permission error, got: %s", err) + if err = posixStorage.DeleteFile("bin", "yes"); err != errFileAccessDenied { + t.Errorf("expected: %s, got: %s", errFileAccessDenied, err) } } @@ -792,8 +792,8 @@ func TestDeleteFile(t *testing.T) { t.Errorf("Unable to initialize posix, %s", err) } - if err = posixStorage.DeleteFile("bin", "yes"); !os.IsPermission(err) { - t.Errorf("expected: Permission error, got: %s", err) + if err = posixStorage.DeleteFile("bin", "yes"); err != errFileAccessDenied { + t.Errorf("expected: %s, got: %s", errFileAccessDenied, err) } }