From db778aae7db844e77b602816a4fd0aeab5d6857e Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 25 Mar 2018 21:02:33 +0200 Subject: fusefrontend: handle empty xattrs efficiently We handle empty files by storing an actual empty file on disk. Handle xattrs similarily and encrypt the empty value to the empty value. --- internal/fusefrontend/fs.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'internal') diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index 738f113..e246264 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -348,7 +348,11 @@ func (fs *FS) StatFs(path string) *fuse.StatfsOut { // decryptSymlinkTarget: "cData64" is base64-decoded and decrypted // like file contents (GCM). +// The empty string decrypts to the empty string. func (fs *FS) decryptSymlinkTarget(cData64 string) (string, error) { + if cData64 == "" { + return "", nil + } cData, err := fs.nameTransform.B64.DecodeString(cData64) if err != nil { return "", err @@ -409,7 +413,11 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) { // encryptSymlinkTarget: "data" is encrypted like file contents (GCM) // and base64-encoded. +// The empty string encrypts to the empty string. func (fs *FS) encryptSymlinkTarget(data string) (cData64 string) { + if data == "" { + return "" + } cData := fs.contentEnc.EncryptBlock([]byte(data), 0, nil) cData64 = fs.nameTransform.B64.EncodeToString(cData) return cData64 -- cgit v1.2.3