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

wrong cache directories #7445

Closed
ThomasWaldmann opened this issue Mar 15, 2023 · 14 comments · Fixed by #7448
Closed

wrong cache directories #7445

ThomasWaldmann opened this issue Mar 15, 2023 · 14 comments · Fixed by #7448

Comments

@ThomasWaldmann
Copy link
Member

ThomasWaldmann commented Mar 15, 2023

From a discussion post:

I noticed that with borg 2 the cache directories do not contain the
name borg which is a bit annoying and i would prefer the old behaviour.

Borg 1.2
/home/dietmar/.cache/borg/0a2cb8f22adaa78a1863b028f3d1629393ef0fdd99b3b61c11d871de9eaaee8b/README

Borg 2.0.0b5
/home/dietmar/.cache/fa673b73240ed3b75ba947fd98787fdf8ecd17204323e4a10c2754cdcc5fd547/README

this is likely due to us switching to platformdirs library and the related api change.

config directories need also checking, there might be the same issue.

@ThomasWaldmann
Copy link
Member Author

ThomasWaldmann commented Mar 15, 2023

Likely the issue happened on Linux.

It looks OK on macOS:

  • config: /Users/tw/Library/Application Support/borg
  • cache: /Users/username/Library/Caches/borg

@nain-F49FF806
Copy link
Contributor

Hi. I would like to look into this. First step for me I guess would be replicating it on my device. (and looking at the relevant code)

Could you mention the email thread subject so I can read more?

@ThomasWaldmann
Copy link
Member Author

#7392 (reply in thread) see there.

@nain-F49FF806
Copy link
Contributor

I suppose #7300 (mentioned earlier) , #7332 are related to this. Am going afk now.
Will check again tomorrow. (if it's still open :)

@nain-F49FF806
Copy link
Contributor

nain-F49FF806 commented Mar 16, 2023

I think this might be the offending line

borg/src/borg/helpers/fs.py

Lines 145 to 146 in 270b705

config_dir = os.environ.get(
"BORG_CONFIG_DIR", join_base_dir(".config", legacy=legacy) or platformdirs.user_config_dir("borg")

join_base_dir(".config", legacy=legacy) should instead be join_base_dir(".config", "borg", legacy=legacy)

@ThomasWaldmann
Copy link
Member Author

For comparison:

https://github.com/borgbackup/borg/blob/1.2.3/src/borg/helpers/fs.py#L105

Yes, I think you maybe discovered an issue there (but that is only for the case when BORG_BASE_DIR is used, which is not the default use case).

Also the tests need checking and extending - we have tests whether the new code behaves compatible to the old (1.2.x) code except for expected exceptions.

@nain-F49FF806
Copy link
Contributor

I am running 8027c7b to test. I can't seem to replicate the behavior mentioned above. I get the usual ~/.cache/borg dir.

Ubuntu 20.04

@nain-F49FF806
Copy link
Contributor

nain-F49FF806 commented Mar 16, 2023

Will try the exact release. ...

Same on release borg 2.0.0b5 🙎 🤔

@nain-F49FF806
Copy link
Contributor

nain-F49FF806 commented Mar 16, 2023

I tried platformdirs.user_config_dir("borg") with platformdirs version 3.1.0 on Ubuntu 20.04, and it gives the expected "/home/user/.config/borg" value.

Similarly on Fedora.

So at-least on these two (and other Linux distros), platformdirs may not be the culprit.

@nain-F49FF806
Copy link
Contributor

Just ran manual testing on 1.2.3 vs 2.0.0b5, both with the BORG_BASE_DIR set. Can confirm the difference in behavior.
The later version looses borg subdir

(borg-env):/tmp$ tree -a -L 2 borg1.2.3/
borg1.2.3/
|-- .cache
|   `-- borg
`-- .config
    `-- borg
(borg-env):/tmp$ tree -a -L 2 borg2/    
borg2/
|-- .cache
|   |-- CACHEDIR.TAG
|   `-- df4e4ae7737b68eeb241f01fc1bffee4f5fdda570a238815d05a2f2f1b756eaa
`-- .config
    `-- security

Seems like that is the issue here.

@nain-F49FF806
Copy link
Contributor

Will look into the tests.

nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this issue Mar 17, 2023
@nain-F49FF806
Copy link
Contributor

Submitted a commit fixing the issue for config dir. Should the same fix be applied for the cache dir?

Or is cache dir compatibility when using BORG_BASE_DIR not necessary?
I can imagine BORG_BASE_DIR would generally be borg specific and exclusive, so adding a sub-directory borg under cache there feels redundant.

But it would make sense to do it for consistency, seeing as config's location perhaps should remain compatible between versions.

nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this issue Mar 18, 2023
Make sure the result of get_cache_dir
matches pre and post borgbackup#7300 where desired
@ThomasWaldmann
Copy link
Member Author

I think we should have config and cache dir work as compatible to previously ("legacy") as possible.
There are some expected changes (like on macOS), but we shouldn't have unexpected ones.

@nain-F49FF806
Copy link
Contributor

Acknowledged. Have submitted commits for both. Open to feedback if some changes are required.

nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this issue Mar 29, 2023
nain-F49FF806 added a commit to nain-F49FF806/borg that referenced this issue Mar 29, 2023
Make sure the result of get_cache_dir
matches pre and post borgbackup#7300 where desired
ThomasWaldmann pushed a commit that referenced this issue Mar 29, 2023
fix config dir compatibility issue, fixes #7445

- add tests
- make sure the result of get_cache_dir matches pre and post #7300 where desired
- harmonize implementation of config_dir_compat and cache_dir_compat tests

Co-authored-by: nain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants