From 1f91de1daeef4c5b52c132786d71c9e7007f0db2 Mon Sep 17 00:00:00 2001 From: Costa Huang Date: Fri, 16 Nov 2018 17:13:07 -0500 Subject: [PATCH] API-1 # Create the backup folder first This fixes the bug that users without attachments will not be able to write to `./portwarden_backup/main.json` --- core.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core.go b/core.go index 51e9dc6..20c693a 100644 --- a/core.go +++ b/core.go @@ -78,6 +78,9 @@ func CreateBackupBytes(passphrase, sessionKey string, sleepMilliseconds int) ([] if err := json.Unmarshal(rawByte, &pwes); err != nil { return nil, err } + if err = os.MkdirAll(BackupFolderName, os.ModePerm); err != nil { + return nil, err + } err = BWGetAllAttachments(BackupFolderName, sessionKey, pwes, sleepMilliseconds) if err != nil { return nil, err