For Linux Snap, move local storage, etc. to SNAP_USER_COMMON

This commit is contained in:
Ben Gotow 2017-10-20 00:07:22 -07:00
parent 515b01de84
commit f0c45d7c4e
2 changed files with 13 additions and 5 deletions

View file

@ -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;
};

View file

@ -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