fix: Delete dir failed when .DS_Store in it (#17352)

This commit is contained in:
jiuker 2023-06-07 01:12:06 +08:00 committed by GitHub
parent 123a2fb3a8
commit 5a21b1f353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2077,6 +2077,18 @@ func (s *xlStorage) deleteFile(basePath, deletePath string, recursive, force boo
if isObjectDir { if isObjectDir {
return errFileNotFound return errFileNotFound
} }
// if we have .DS_Store only on macOS
if runtime.GOOS == globalMacOSName {
storeFilePath := pathJoin(deletePath, ".DS_Store")
_, err := Stat(storeFilePath)
// .DS_Store exsits
if err == nil {
// delete first
Remove(storeFilePath)
// try again
Remove(deletePath)
}
}
// Ignore errors if the directory is not empty. The server relies on // Ignore errors if the directory is not empty. The server relies on
// this functionality, and sometimes uses recursion that should not // this functionality, and sometimes uses recursion that should not
// error on parent directories. // error on parent directories.