From 5a21b1f35336235d1fce24a5a0d30657b9ba7539 Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Wed, 7 Jun 2023 01:12:06 +0800 Subject: [PATCH] fix: Delete dir failed when .DS_Store in it (#17352) --- cmd/xl-storage.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index af148f8c6..f9726d7d6 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -2077,6 +2077,18 @@ func (s *xlStorage) deleteFile(basePath, deletePath string, recursive, force boo if isObjectDir { 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 // this functionality, and sometimes uses recursion that should not // error on parent directories.