aboutsummaryrefslogtreecommitdiff
path: root/internal/nametransform
diff options
context:
space:
mode:
authorSebastian Lackner2018-12-29 23:55:50 +0100
committerrfjakob2019-01-01 16:09:57 +0100
commit87ced5f95d151c51eecbf17c63114a85af1b5773 (patch)
tree3b2bc4a43eec448a8e7bd9c20e6e6b008502d0b1 /internal/nametransform
parent3dd5a6c069a88765a7d9ecf2d077b9467cece820 (diff)
nametransform: Delete incomplete longname files on error.
Diffstat (limited to 'internal/nametransform')
-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
}