FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
13.37k stars 825 forks source link

Store data and settings in portable directory with portable version #746

Open zahroc opened 3 years ago

zahroc commented 3 years ago

It seems that the portable version store its settings and data within the AppData folder structure in Windows. For a portable application, the data and settings should reside within the application's directory.

rddim commented 3 years ago

@zahroc

You can use FreeTubePortable as a workaround. Its deal also with the registry strings.

zahroc commented 3 years ago

Correct, that is why I think the portable version should NOT use the registry settings. It should keep the data within the portable directory.

Snake883 commented 3 years ago

I'm using the portable version. It is saving to: %AppData%\Roaming\FreeTube

One of the bigger problems I have is I run the portable version from a network share. The portable version isn't using the network share.

rddim commented 3 years ago

@snakyjake1

I make some tests and:

1) If you run it from \\server\share the GUI will not appear on the screen but the %AppData\Roaming\FreeTube will be created, also some FreeTube.exe processes are started (check Task Manager).

2) But if you map your network share as drive with letter (for example Z:\) FreeTube will work, of course will store the settings in the %AppData%\Roaming\FreeTube on your device. In my case it starts slowly from the mapped network share.

In the next release I will change the SupportsUNC=yes to SupportsUNC=no for the portable launcher that I maintain. This will not running the FreeTubePortable from \\server\share and will inform the user why this happen.

zahroc commented 3 years ago

Is it possible to add a config variable to place the configuration in a user specified location and not %AppData%..... not matter where it is run from? This was my original post subject.

GilgusMaximus commented 3 years ago

At the moment, the data path is hardcoded as the path Electron uses by default

rddim commented 3 years ago

I found this code https://github.com/getferdi/ferdi/blob/develop/src/index.js#L13:L23

And modified the index.js with the code below and it's working.

...
import Datastore from 'nedb'

const path = require('path')

// Set app directory before loading user modules
if (process.env.FREETUBE_APPDATA_DIR != null) {
  app.setPath('appData', process.env.FREETUBE_APPDATA_DIR)
  app.setPath('userData', path.join(app.getPath('appData')))
} else if (process.env.PORTABLE_EXECUTABLE_DIR != null) {
  app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`)
  app.setPath('userData', path.join(app.getPath('appData'), `${app.name}AppData`))
} else if (process.platform === 'win32') {
  app.setPath('appData', process.env.APPDATA)
  app.setPath('userData', path.join(app.getPath('appData'), app.name))
}

require('electron-context-menu')({
...

I move the const path = require('path') to be after line 3 import Datastore from 'nedb' because of error 'path' was used before it was defined no-use-before-define.

With the environment FREETUBE_APPDATA_DIR the whole data is stored in a folder that I want, but there is one little issue: the empty folder Dictionaries is still created in %AppData%\FreeTube.

Please note that I'm not a programmer. I hope this code will help to created trully portable FreeTube.

GilgusMaximus commented 3 years ago

Hi, so thanks for checking on this. It'd be great if you could create a Draft Pull Request for any code changes for this issue. Then it is easier to discuss and direct any necessary changes :)

nulledone commented 2 years ago

Any updates on this? App's still not portable.

rddim commented 2 years ago

Adding a --user-data-dir= to the Target field on the shortcut will save the data and the settings anywhere you want. For example: path\to\FreeTube.exe --user-data-dir=.\Data will create a folder Data in the same folder where is the FreeTube.exe (don't miss the dot after =). Note: This will not prevent creating a strings in the registry.

I will add this argument to the next release of FreeTube in PA.com format. In my case the data folder size is reduced (I re-create the profile) and the app start more faster, may be because of not moving the data to %AppData%. I also try this cmd line argument with some other electron apps and it work.

Gevaarlijk commented 1 year ago

Is there an eta for the fix?

MilesFarber commented 1 year ago

So after 3 years, the portable version is still not portable.

STPKITT commented 1 year ago

https://github.com/deltachat/deltachat-desktop is also Electron based and has a working portable variant so I guess everything needed should be in it's source code.

andrienko commented 5 months ago

On Windows, I ended up simply symlinking (via hard link, directory junction or whatever they call it) the local folder to appdata.:

mklink /J c:\Users\user\AppData\Roaming\FreeTube d:\Soft\FreeTube\data

(with AppData\Roaming\FreeTube not existing and d:\Soft\FreeTube\data existing, of course)

Which produces something like Junction created for c:\Users\user\AppData\Roaming\FreeTube <<===>> d:\Soft\FreeTube\data

And now I have a folder-link in AppData (I can safely delete that link too, without damaging the data folder on D:, just in case) Works just fine, no performance issues (at least yet). No fiddling with arguments, too.

And, most important, the privacy redirect and freetube:// protocol working fine (could not find an easy way to provide arguments to freetube:// protocol)