adopted-ember-addons / ember-electron

:zap: Build, test, compile and package desktop apps with Ember and Electron
https://ember-electron.js.org/
Other
805 stars 109 forks source link

Beta: app.getPath('userData') returns Electron default. #199

Closed kara-todd closed 6 years ago

kara-todd commented 7 years ago

Hello! I was poking around converting my project to the 2.x branch and I ran into a strange issue.

I had previously been storing some data in the user directory app which I found using app.getPath('userData'). This correctly returned the expected ~/Library/Application Support/<appname from package.json>. However, after switching to the 2.x branch I am now getting ~/Library/Application Support/Electron and pretty much all of the app calls seem to be returning the default Electron data rather than info about my partiuclar app.

It seems this could be the same issue reported here but I wasn't sure how this translates to the ember-electon setup...

I know the 2.x branch is still not released yet so I hope this isn't too early to submit an issue. Any help I could get would be great! :)

makepanic commented 7 years ago

How I understand it, with the move to electron-forge, the app name won't get set in development mode. If you bundle it for production, userData should point to the correct path again.

anulman commented 7 years ago

This is correct, thanks @makepanic. @kara-todd is this causing errors for you?

kara-todd commented 7 years ago

@anulman sorry for the delay in response.

Yes, basically, I have an 'import' function where I need to copy files from the user's system and store them in the app (in this case the ~/Library/Application Support directory.) Additionally, the user can "upload" photos which need to be stored and then later referenced.

I managed to work around this by adding the following:

// ember-electron/lib/index.js

app.setName(appName);
app.setPath('userData', app.getPath('userData').replace(/Electron/i, appName));

This seems to work around the issue for me when running ember electron, but it seems a bit hacky? I just wasn't sure if this was an intended behavior.

bendemboski commented 6 years ago

This is the expected behavior in development mode for electron-forge. The closest relevant issue is this one, which references this PR in electron-prebuilt-compile, and in which the discussion reveals that it only addresses app.getName() and app.getVersion(), not the application paths. If somebody want to get the paths addressed, an issue should be opened in electron-prebuilt-compile. I'm closing this issue.