aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pathfs_frontend/file.go2
-rw-r--r--pathfs_frontend/file_holes.go2
-rw-r--r--pathfs_frontend/fs.go13
-rw-r--r--pathfs_frontend/fs_dir.go2
4 files changed, 19 insertions, 0 deletions
diff --git a/pathfs_frontend/file.go b/pathfs_frontend/file.go
index cf6b192..1f71bfb 100644
--- a/pathfs_frontend/file.go
+++ b/pathfs_frontend/file.go
@@ -1,5 +1,7 @@
package pathfs_frontend
+// FUSE operations on file handles
+
import (
"bytes"
"fmt"
diff --git a/pathfs_frontend/file_holes.go b/pathfs_frontend/file_holes.go
index 3db4828..fd2e2c1 100644
--- a/pathfs_frontend/file_holes.go
+++ b/pathfs_frontend/file_holes.go
@@ -1,5 +1,7 @@
package pathfs_frontend
+// Helper functions for sparse files (files with holes)
+
import (
"github.com/hanwen/go-fuse/fuse"
"github.com/rfjakob/gocryptfs/cryptfs"
diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go
index f853556..e930228 100644
--- a/pathfs_frontend/fs.go
+++ b/pathfs_frontend/fs.go
@@ -1,5 +1,7 @@
package pathfs_frontend
+// FUSE operations on paths
+
import (
"encoding/base64"
"os"
@@ -300,6 +302,17 @@ func (fs *FS) Rename(oldPath string, newPath string, context *fuse.Context) (cod
fs.CryptFS.DirIVCacheEnc.Clear()
err = os.Rename(cOldPath, cNewPath)
+
+ if lerr, ok := err.(*os.LinkError); ok && lerr.Err == syscall.ENOTEMPTY {
+ // If an empty directory is overwritten we will always get
+ // ENOTEMPTY as the "empty" directory will still contain gocryptfs.diriv.
+ // Handle that case by removing the target directory and trying again.
+ cryptfs.Debug.Printf("Rename: Handling ENOTEMPTY\n")
+ if fs.Rmdir(newPath, context) == fuse.OK {
+ err = os.Rename(cOldPath, cNewPath)
+ }
+ }
+
return fuse.ToStatus(err)
}
diff --git a/pathfs_frontend/fs_dir.go b/pathfs_frontend/fs_dir.go
index 9b319f8..0f255d9 100644
--- a/pathfs_frontend/fs_dir.go
+++ b/pathfs_frontend/fs_dir.go
@@ -1,5 +1,7 @@
package pathfs_frontend
+// Mkdir and Rmdir
+
import (
"fmt"
"os"