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

use relative paths in config file #78

Merged
merged 9 commits into from
Nov 8, 2023
Prev Previous commit
Next Next commit
handle 8.3 filenames in Repository.save_config()
dennisvang committed Sep 6, 2023
commit 076905170ecb09f58c77b73602eae935aebddda0
11 changes: 8 additions & 3 deletions src/tufup/repo/__init__.py
Original file line number Diff line number Diff line change
@@ -580,12 +580,17 @@ def save_config(self):
for key in ['repo_dir', 'keys_dir']:
try:
temp_config_dict[key] = temp_config_dict[key].relative_to(
pathlib.Path.cwd()
# resolve() is necessary on windows, to handle "short"
# path components (a.k.a. "8.3 filename" or "8.3 alias"),
# which are truncated with a tilde,
# e.g. c:\Users\RUNNER~1\...
pathlib.Path.cwd().resolve()
)
except ValueError:
logger.warning(
f'Saving *absolute* path in config, because the path is'
f' not relative to cwd: {temp_config_dict[key]}'
f'Saving *absolute* path to config, because the path'
f' ({temp_config_dict[key]}) is not relative to cwd'
f' ({pathlib.Path.cwd()})'
)
# write file
config_file_path.write_text(