fusefrontend: reorder logic in Rmdir to get rid of one indentation level
Handle the errors first so that the normal code path is not indented. This should not cause any behavoir changes.
This commit is contained in:
parent
3a5a783b54
commit
6f3b65d924
|
@ -175,9 +175,20 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
|
|||
}
|
||||
dirfd := os.NewFile(uintptr(dirfdRaw), cName)
|
||||
defer dirfd.Close()
|
||||
|
||||
// Check directory contents
|
||||
children, err := dirfd.Readdirnames(10)
|
||||
if err == nil {
|
||||
if err == io.EOF {
|
||||
// The directory is empty
|
||||
tlog.Warn.Printf("Rmdir: %q: gocryptfs.diriv is missing", cPath)
|
||||
err = syscall.Rmdir(cPath)
|
||||
if err != nil {
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
tlog.Warn.Printf("Rmdir: Readdirnames: %v", err)
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
// If the directory is not empty besides gocryptfs.diriv, do not even
|
||||
// attempt the dance around gocryptfs.diriv.
|
||||
if len(children) > 1 {
|
||||
|
@ -216,17 +227,6 @@ func (fs *FS) Rmdir(path string, context *fuse.Context) (code fuse.Status) {
|
|||
if err != nil {
|
||||
tlog.Warn.Printf("Rmdir: Could not clean up %s: %v", tmpName, err)
|
||||
}
|
||||
} else if err == io.EOF {
|
||||
// The directory is empty
|
||||
tlog.Warn.Printf("Rmdir: %q: gocryptfs.diriv is missing", cPath)
|
||||
err = syscall.Rmdir(cPath)
|
||||
if err != nil {
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
} else {
|
||||
tlog.Warn.Printf("Rmdir: Readdirnames: %v", err)
|
||||
return fuse.ToStatus(err)
|
||||
}
|
||||
// Delete .name file
|
||||
if nametransform.IsLongContent(cName) {
|
||||
nametransform.DeleteLongName(parentDirFd, cName)
|
||||
|
|
Loading…
Reference in New Issue