CircuitCoder / Console-Lite

Console-Lite
https://easymun.com/console-lite
MIT License
24 stars 6 forks source link

[Bug] MacOS Sierra 10.12.4 Initialization Always Failed #14

Closed XieJiSS closed 6 years ago

XieJiSS commented 6 years ago

Well, this bug will only occur on MacOS, since server use ${__dirname}/storage/ as a folder to save user data, however on mac you cannot write that read-only folder (which will be actually /private/blablabla/Console Lite.app/path/to/your/script).

in this answer https://stackoverflow.com/questions/38067298/saving-files-locally-with-electron it is said that developers could use app.getPath('userData') (in most cases that will be ${process.env.HOME}/Library/Application Support/Name-Of-The-App/) to store data.

As I have figured out, maybe you should use something like fs.mkdir(app.getPath('userData') + '/storage') and fs.mkdir(app.getPath('userData') + '/storage/main.db'), etc. to avoid raising IO Error: No such file or directory, and handle the err argument of the callback function correctly since the err might told you that the directory already exists (which shouldn't be handled as an error).

That would be similar in ipcMain.on('doImport', ...) and setupExportHandler(...).

By the way: