Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why two different filenames for fit files? #63

Open
cristian5th opened this issue Jun 8, 2021 · 2 comments
Open

Why two different filenames for fit files? #63

cristian5th opened this issue Jun 8, 2021 · 2 comments

Comments

@cristian5th
Copy link
Contributor

Hello.

This is not really an issue. It Is more a doubt I'm having. But I don't know where to ask for this other than here.

When args.format=original, the name used to check if the fit file was already existing is created and stored into a variable like this:
fit_filename = os.path.join(directory, prefix + 'activity_' + activity_id + append_desc + '.fit')

But when the file is physically written into the disk, a new name is created for the fit file, like this:
new_name = os.path.join(directory, prefix + 'activity_' + name_base + append_desc + name_ext)

My doubt is that name_base and activity_id are not necessary the same thing. Actually, you had to recently add a workaround because in 2020 Garmin added '_ACTIVITY' to the name in the ZIP.

Why not use activity_id when writing the file into the disk? Is there any particular reason that I'm missing?

Thank you. Regards.

@pe-st
Copy link
Owner

pe-st commented Jun 14, 2021

Good point.

The code to unzip was added in commit e12a7a5 almost 6 years ago, way before my first contribution.

Basically new_name uses the filename stored in the ZIP as it loops over all files in the ZIP, but I guess that the ZIP never contains more than one file. If there were more than one then using the same file name for all of them would then keep only one. But probably it would be better to take only the first file from the ZIP and do some error handling/raise a warning if there are more.

@bxsx
Copy link
Contributor

bxsx commented May 29, 2022

My "two" cents.

  1. The safest option is to preserve the original file name.
  2. It is also quite "safe" to amend the filename by adding a prefix and/or a suffix.
  3. The most powerful would be templates. I imagine passing an argument like --filename '$start_time-$activity_id-$desc or whatever --fn_format=%Y%M%D%H%M-%ID-%DESC. Or even allow data evaluation --fn_template='A[startTimeLocal]-G[customMakeModel]' ;) This would give the user full control over the filenames.

The second option is currently supported[1].

However, to be consistent across all supported files, it is true that it would be safer to use activity_id as requested in #66

@cristian5th Actually, you had to recently add a workaround because in 2020 Garmin added '_ACTIVITY' to the name in the ZIP.

[1] Until we forget about this workaround ;)
And while I personally find this workaround useful, I have some doubts as to whether it should be in the repository.

@pe-st If there were more than one then using the same file name for all of them would then keep only one. But probably it would be better to take only the first file from the ZIP and do some error handling/raise a warning if there are more.

In that case, I would suggest adding the suffix -N where N is the file number: -1, -2, ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants