macos: don't throw IO errors because of .DS_Store files

MacOS creates lots of these files, and if the directory is otherwise
empty, we would throw an IO error to the unsuspecting user.

With this patch, we log a warning, but otherwise pretend we did not
see it.

Mitigates https://github.com/rfjakob/gocryptfs/issues/140
This commit is contained in:
Jakob Unterwurzacher 2017-09-05 21:47:05 +02:00
parent 538cae610c
commit 3a5a783b54

View File

@ -7,6 +7,7 @@ import (
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"sync" "sync"
"syscall" "syscall"
@ -324,6 +325,11 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
if err != nil { if err != nil {
tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v", tlog.Warn.Printf("OpenDir %q: invalid entry %q: %v",
cDirName, cName, err) cDirName, cName, err)
if runtime.GOOS == "darwin" && cName == ".DS_Store" {
// MacOS creates lots of these files. Log the warning but don't
// increment errorCount - does not warrant returning EIO.
continue
}
errorCount++ errorCount++
continue continue
} }