ssaring / sportstracker

SportsTracker is a desktop application for people who want to record and analyze their sporting activities.
148 stars 55 forks source link

Unified data directory to sync across multiple devices? #152

Open manuelmarque opened 7 years ago

manuelmarque commented 7 years ago

Dear Stefan, First of all, amazing work! I have been using SportsTracker for almost 2 years now and it is an excellent piece of software - I have had a hard time finding something which would be flexible enough to accommodate all the different sports I do (rowing, running, road cycling), and their relevant equipment. Great job!

Since I have more than one machine (a desktop running Fedora 24 and a laptop running Windows 10) I would love to have my data on both machines. I have used Dropbox in the past, symlinking the config directory to a folder in my Dropbox on both machines. This worked, provided that the directory structure on both machines was the same (which I could do, since in the past I had two Linux machines), and that my workout data (the .fit and .gpx files) was also stored in the same location (no problem with that, since I have everything on Dropbox). Unfortunately, with Windows the directory structure is altered; would it be possible to define a relative path around the user's home folder? Not sure if I'm being clear enough or if I'm asking the impossible here :-)

Anyway, thanks for the software and keep up the good work!

Best wishes, Manuel.

ssaring commented 7 years ago

Hi Manuel, thanks for your nice feedback.

Currently it's only possible to specify a directory as a startup parameter where the SportsTracker XML / database files are located. So it's possible to use one e.g. DropBox location on many computers. Details are documented in the README.txt. Unfortunately there's currently no way to specify a default directory where all the HRM / exercise files are located. If you would use multiple macOS or Linux systems, this would be no problem. You could just setup a symlink to the directory on each system, then it's possible to find the file on each computer by using the symlink reference. This is not possible on Windows due to the "drive letter technology" :(

Maybe it would be a good idea to add an option for a default directory where the exercise files can be located when a relative reference is used.

Bye, Stefan

arampp commented 7 years ago

Just an idea: If paths in exercises.xml would be relative ones, the dropbox solution would work. Perhaps there could be a configuration option if path should be absolute or relative.

ssaring commented 7 years ago

@BitSchupser Thanks for your idea. This solution doesn't make sure that the same relative paths are working on different systems. The relative path to the HRM file must be in the same synced container and the relative path from the user application directory to the synced container is mostly not the same on different systems. It can work, but the user must always take care of it.

I would prefer a simpler solution for that problem, one which can be understood by the average user (who don't care about absolute or relative paths).

What about this?

Users which want to use the same data on multiple systems just need to start SportsTracker with the custom application data directory option and store all exercise files inside that directory.

svesa11 commented 6 years ago

Hallo Stefan,

leider habe ich das gleiche Problem mit diesem genialen Programm und verstehe die Antwort oben nicht. Ich starte SportsTracker immer mit der Option "datadir" und habe auch alle meine HRM-Dateien in diesem Verzeichnis abgelegt. Wie gebe ich nun einen "relativen" Pfad für eine Datei an, dass diese auf meinem Win10-Laptop und auf meinem Ubuntu-PC gefunden werden?

Grüße sven

ssaring commented 6 years ago

Hallo Sven,

ich antworte mal besser auf Deutsch, sonst hättest du evtl. die Antwort selbst erkannt (ist kein Problem). Bislang fehlt eine Funktion, dass die HRM-Dateien der Trainingseinträge über relative Pfade gespeichert werden. Für macOS und Linux-Nutzer kein Problem, Symlink erstellen und die Dateien werden auf beiden Rechnern gefunden. Windows-Nutzer beissen jedoch wegen der altertümlichen Laufwerksbuchstaben in die Tischkante :)

Dieses Issue ist ein Feature Request, damit relative Dateinamen verwendet werden, wenn die HRM-Dateien im Anwendungsverzeichnis liegen. Leider wurde es noch nicht umgesetzt, der Bedarf war wohl noch bei niemandem groß genug...

Grüße, Stefan

svesa11 commented 6 years ago

Hallo Stefan,

thank you for this answer: it gave me the idea for a solution: you still have done it!!! Maybe it is possible to start SportsTracker with a second parameter: first is "--DataDir" and second is "--ExerciseDir". Or the other way: when "--DataDir" is given, then the program looks as standard for exercises in "--ataDir[SubDir]"

Maybe this helps, but I'm not a programmer, so maybe this is stupid.

greetings sven

ssaring commented 6 years ago

I don't think we need an additional parameter here. Take a look at my comment from 04. Januar: when the HRM file is located inside the data directory or in an subdirectory, then the relative path needs to be stored. If the HRM file is located outside the data directory, then the full path needs to be stored. This solves the problem of cross platform usage for Linux/Windows/macOS completely, the user just need to put all HRM files to the data directory or some subdirectory.

svesa11 commented 6 years ago

Sorry, but I don't understand : what do you mean with "when the HRM file is located inside the data directory or in an subdirectory, then the relative path needs to be stored"? What do you mean with "relative path"? For example, I start with --datadir=/home/sven/ST and my HRM-file "exercise.fit" is inside this directory: what is the correct path I have to give in the field "Einheit bearbeiten/Optional/HRM-Datei:" ? I tested to write in this field onle the name of the exercise, but then Sportstracker gives an error: "Fehler beim Lesen oder Parsen der HRM-Datei...". It doesn't change if I put "./" or ".\" or just "." in front of the filename.

Sorry for this, maybe stupid, question, but I'm not a programmer only a DAU ;-) sven

ssaring commented 6 years ago

This issue is a planned enhancement and has not been implemented yet. So it doesn't work ;)

When ready, then the user has no to worry about absolute or relative files. When he adds an file to an exercise which is located in the data directory, then the relative filename will be stored, otherwise the absolute filename. So all the files inside the data directory will be found on Windows, Mac and Linux systems when sharing the same data folder.

svesa11 commented 6 years ago

I'm sorry! my english is too bad! I understood, that it is just implemented. Thank you for your great work!

greetings sven

ssaring commented 6 years ago

No problem, Sven. It's always good to get feadback, the english quality does not matter.

jacobilsoe commented 4 years ago

I don't know the code base well, so any thoughts on where it would be best to implement this?

Exercise.getHrmFile() is called from multiple places so one idea could be to ensure that the Exercise instance always represents the correct path value for the HrmFile. This could be done in XMLExerciseList by setting the HrmFile to either an absolute value as specified in exercises.xml or the absolute value of the data directory combined with the relative value specified in exercises.xml.

But from what I can see this would break Exercise cloning and SQLiteExporter.

Maybe adding a Exercise.getHrmFileAbsolutePath()?

ssaring commented 4 years ago

I would prefer when the STDocument class would be responsible for resolving the HRM filenames. We could add a method resolveAbsoluteHrmFilename(String hrmFilename): String. STDocuments knows the data directory, if present. So it could check whether the passed filename is relative and resolve the name. STDocument is also responsible for saving the exercise list, so the migration could also be done there. Or we implement a dedicated class for HRM file handling if it gets to complex and STDocument uses that class.

@jacobilsoe What do you think? I have not checked the details, maybe there are some issues we've not seen yet.

jacobilsoe commented 3 years ago

Afraid I haven't had time to work on this and won't have for the near future. I would be a nice feature to have though.