fusefrontend: Use openBackingPath in Unlink and simplify code

This commit is contained in:
Sebastian Lackner 2017-11-28 01:28:29 +01:00 committed by rfjakob
parent 2591900b69
commit 5d44a31b41
1 changed files with 8 additions and 18 deletions

View File

@ -382,15 +382,7 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
if fs.isFiltered(path) {
return fuse.EPERM
}
cPath, err := fs.getBackingPath(path)
if err != nil {
return fuse.ToStatus(err)
}
cName := filepath.Base(cPath)
if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) {
var dirfd *os.File
dirfd, err = os.Open(filepath.Dir(cPath))
dirfd, cName, err := fs.openBackingPath(path)
if err != nil {
return fuse.ToStatus(err)
}
@ -400,15 +392,13 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
if err != nil {
return fuse.ToStatus(err)
}
// Delete ".name"
// Delete ".name" file
if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) {
err = nametransform.DeleteLongName(dirfd, cName)
if err != nil {
tlog.Warn.Printf("Unlink: could not delete .name file: %v", err)
}
return fuse.ToStatus(err)
}
err = syscall.Unlink(cPath)
return fuse.ToStatus(err)
}