Freetube: Store data and settings in portable directory with portable version

Created on 30 Oct 2020  路  8Comments  路  Source: FreeTubeApp/FreeTube

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.

enhancement

All 8 comments

@zahroc

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

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

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.

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

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.

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

linuxgirl22 picture linuxgirl22  路  5Comments

e-buttelli picture e-buttelli  路  3Comments

martinmurciego picture martinmurciego  路  6Comments

jibe-b picture jibe-b  路  3Comments

wildcard-f8 picture wildcard-f8  路  5Comments