From f0c45d7c4ec12ec7821c427d323ef3d2ab9f5afa Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 20 Oct 2017 00:07:22 -0700 Subject: [PATCH] For Linux Snap, move local storage, etc. to SNAP_USER_COMMON --- app/src/browser/main.js | 17 +++++++++++++---- snap/snapcraft.template.yaml | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/browser/main.js b/app/src/browser/main.js index a59b1590c..0339bf1a4 100644 --- a/app/src/browser/main.js +++ b/app/src/browser/main.js @@ -16,16 +16,25 @@ if (typeof process.setFdLimit === 'function') { } const setupConfigDir = args => { - let defaultDirName = 'Mailspring'; + let dirname = 'Mailspring'; if (args.devMode) { - defaultDirName = 'Mailspring-dev'; + dirname = 'Mailspring-dev'; } if (args.specMode) { - defaultDirName = 'Mailspring-spec'; + dirname = 'Mailspring-spec'; } - const configDirPath = path.join(app.getPath('appData'), defaultDirName); + let configDirPath = path.join(app.getPath('appData'), dirname); + if (process.platform === 'linux' && process.env.SNAP) { + // for linux snap, use the sandbox directory that is persisted between snap revisions + configDirPath = process.env.SNAP_USER_COMMON; + } + + // crete the directory mkdirp.sync(configDirPath); + // tell Electron to use this folder for local storage, etc. as well + app.setPath('userData', configDirPath); + return configDirPath; }; diff --git a/snap/snapcraft.template.yaml b/snap/snapcraft.template.yaml index 41d1c9bca..5144fac13 100644 --- a/snap/snapcraft.template.yaml +++ b/snap/snapcraft.template.yaml @@ -40,7 +40,6 @@ apps: # ensure libappindicator has readable resources. environment: HOME: $SNAP_USER_COMMON - XDG_CONFIG_HOME: "$SNAP_USER_COMMON/.config" TMPDIR: $XDG_RUNTIME_DIR plugs: - avahi-observe