FreeTube icon indicating copy to clipboard operation
FreeTube copied to clipboard

Store data and settings in portable directory with portable version

Open zahroc opened this issue 4 years ago • 10 comments

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.

zahroc avatar Oct 30 '20 14:10 zahroc

@zahroc

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

rddim avatar Oct 31 '20 14:10 rddim

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

zahroc avatar Nov 01 '20 14:11 zahroc

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.

Snake883 avatar Nov 15 '20 18:11 Snake883

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

rddim avatar Nov 25 '20 20:11 rddim

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.

zahroc avatar Nov 26 '20 03:11 zahroc

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

GilgusMaximus avatar Nov 26 '20 11:11 GilgusMaximus

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.

rddim avatar Dec 06 '20 21:12 rddim

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 :)

GilgusMaximus avatar Dec 07 '20 11:12 GilgusMaximus

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

nulledone avatar Apr 22 '22 23:04 nulledone

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.

rddim avatar Jun 03 '22 20:06 rddim

Is there an eta for the fix?

Gevaarlijk avatar May 05 '23 15:05 Gevaarlijk

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

MilesFarber avatar Jun 14 '23 08:06 MilesFarber

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.

STPKITT avatar Jun 14 '23 08:06 STPKITT