Skip to content

Commit

Permalink
Workaround for EXDEV error
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Apr 5, 2020
1 parent 514469a commit 26cfa55
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,20 @@ class Conf {
data = Buffer.concat([initializationVector, Buffer.from(':'), cipher.update(Buffer.from(data)), cipher.final()]);
}

// Temporary workaround for Conf being packaged in a Ubuntu Snap app.
// See https://github.com/sindresorhus/conf/pull/82
if (process.env.SNAP) {
try {
// Temporary workaround for Conf being packaged in a Ubuntu Snap app.
// See https://github.com/sindresorhus/conf/pull/82
if (process.env.SNAP) {
fs.writeFileSync(this.path, data);
} else {
writeFileAtomic.sync(this.path, data);
}
} catch (err) {
// Fix for https://github.com/sindresorhus/electron-store/issues/106
// Sometimes on Windows, we will get an EXDEV error when atomic writing
// (even though to the same directory), so we fall back to non atomic write
if (err.code !== 'EXDEV') throw err;
fs.writeFileSync(this.path, data);
} else {
writeFileAtomic.sync(this.path, data);
}
}

Expand Down

0 comments on commit 26cfa55

Please sign in to comment.