summaryrefslogtreecommitdiff
path: root/internal/nametransform/longnames.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/nametransform/longnames.go')
-rw-r--r--internal/nametransform/longnames.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/nametransform/longnames.go b/internal/nametransform/longnames.go
index 01280a8..da18ebb 100644
--- a/internal/nametransform/longnames.go
+++ b/internal/nametransform/longnames.go
@@ -122,10 +122,20 @@ func (n *NameTransform) WriteLongName(dirfd int, hashName string, plainName stri
return err
}
fd := os.NewFile(uintptr(fdRaw), hashName+LongNameSuffix)
- defer fd.Close()
_, err = fd.Write([]byte(cName))
if err != nil {
+ fd.Close()
tlog.Warn.Printf("WriteLongName: Write: %v", err)
+ // Delete incomplete longname file
+ syscallcompat.Unlinkat(dirfd, hashName+LongNameSuffix, 0)
+ return err
}
- return err
+ err = fd.Close()
+ if err != nil {
+ tlog.Warn.Printf("WriteLongName: Close: %v", err)
+ // Delete incomplete longname file
+ syscallcompat.Unlinkat(dirfd, hashName+LongNameSuffix, 0)
+ return err
+ }
+ return nil
}