damienhaynes / TraktRater

TraktRater is a tool written in C# to help users transfer user episode, show and movie user ratings and watchlists from multiple media database sites around the web.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fully portable TraktRater

nidunc opened this issue · comments

Currently, TraktRater stores its settings and logs in %APPDATA%\TraktRater (C:\Users\%USERNAME%\AppData\Roaming\TraktRater by default). This behaviour is hardcoded into the program in those files:

return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"TraktRater", @"Settings.xml");
internal static readonly string LogDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"TraktRater", @"Logs");

This means that TraktRater is not completely portable. While the executable itself can easily be put on a portable storage medium and run as-is on multiple computers (since it does not have to be installed), its settings won’t carry over, so—for example—one would have to re-authenticate to Trakt on every computer (unless one manually copies TraktRater’s AppData\Roaming folder to the other computers).

Especially given that TraktRater is already partially portable, due to the fact that the executable can be run directly without having to install it, in my opinion it would make sense to go all the way and make its settings (and logs/etc.) portable too; i.e., that TraktRater stores them in the same folder as the executable (or perhaps in a subfolder).
This could either be the default behaviour (falling back to the old way if %APPDATA%\TraktRater already exists), or you could add an argument/option that makes TraktRater fully portable when used while executing the executable (e.g., TraktRater_v2.3.10.exe --portable and/or TraktRater_v2.3.10.exe -p).

Would it be possible to implement this?

(Another way to achieve this would be to add an argument --configdir which could have a relative [e.g., TraktRater_v2.3.10.exe --configdir .] or an absolute path [e.g., TraktRater_v2.3.10.exe --configdir "C:\Programs\TraktRater"], but that may be unnecessarily complex. It would be handy for people who manage multiple accounts one one of the supported services, though, but that is outside of the scope of this issue.)


Current file structure (assuming that TraktRater_v2.3.10.exe is placed in C:\Programs\TraktRater)

C
├── Programs
│   └── TraktRater
│       └── TraktRater_v2.3.10.exe
└── Users
    └── %USERNAME%
        └── AppData
            └── Roaming
                └── TraktRater
                    ├── Logs
                    └── Settings.xml

Example of desired file structure (either by default or by running TraktRater_v2.3.10.exe with, e.g., the --portable and/or -p argument)

C
└── Programs
    └── TraktRater
        ├── Logs
        ├── TraktRater_v2.3.10.exe [--portable, -p]
        └── Settings.xml

@nidunc Thanks for the detailed post, I do like this idea. I don't see anything preventing me from doing this.

If I make it portable by default, I will probably add an upgrade step to move the existing settings/logs to the current working directory. There will need to be a check whether or not the directory supports writes and if not, fall back to the old path where it should always be safe to write too.