From 8fca09d853fd855f22841fece838e81a71a37977 Mon Sep 17 00:00:00 2001 From: ycc Date: Sun, 31 Mar 2024 19:39:50 +0200 Subject: [PATCH] Add securefiles directory for storing encrypted files --- client/messagestorage.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/messagestorage.go b/client/messagestorage.go index 56e4bce..5c5caba 100644 --- a/client/messagestorage.go +++ b/client/messagestorage.go @@ -51,9 +51,16 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri if err != nil { return err } - os.WriteFile(hiddenFilename, encData, 0600) + if _, err := os.Stat(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles")); os.IsNotExist(err) { + err = os.MkdirAll(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles"), 0755) + if err != nil { + return err + } + } + os.WriteFile(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles", hiddenFilename), encData, 0600) + // replace f.Data by uuid filename - f.Data = []byte(hiddenFilename) + f.Data = []byte(filepath.Join(cfg.StoragePath, identity.Uuid, "securefiles", hiddenFilename)) } } outbound := true