-
Notifications
You must be signed in to change notification settings - Fork 95
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
Fix leftover directories after tests #2360
Conversation
The way wms_cache was set previously made it so that after each tests run there would be one or more directories leftover in /tmp. This also happened for each start of MSUI. This change makes MSUI use the platform-specific cache directory of the user instead and sets XDG_CACHE_HOME to isolate those between test runs.
31e1765
to
5ec6983
Compare
@@ -151,8 +148,7 @@ class MSUIDefaultConfig: | |||
WMS_preload = [] | |||
|
|||
# WMS image cache settings: | |||
# this changes on any start of msui, use ths msui_settings.json when you want a persistent path | |||
wms_cache = os.path.join(tempfile.TemporaryDirectory().name, "msui_wms_cache") | |||
wms_cache = str(constants.MSUI_CACHE_PATH / "wms_cache") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
# MSUI does not actually support any PyFilesystem2 fs that is not available as a local path | ||
MSUI_CONFIG_SYSPATH = _fs.getsyspath("") | ||
|
||
MSUI_CACHE_PATH = platformdirs.user_cache_path("msui", "mss") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the tutorials I have to remove these data too. There it would be easier to remove only the MSUI_CONFIG_PATH, which I can do by using a config, which I also clear.
Because it wasn't the same dir on a new tutorial I didn't care.
It might easier to have a cache dir below the MSUI_CONFIG_PATH so all is on one place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also before we run tests the platformdirs cache needs to be cleared, or stored randomized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might easier to have a cache dir below the MSUI_CONFIG_PATH so all is on one place.
Cache files don't belong into the configuration directory. There is a reason those are separate XDG directories. As a user I should be able to remove XDG_CACHE_HOME
without any issue and be confident that this has cleared all application caches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also before we run tests the platformdirs cache needs to be cleared, or stored randomized.
That happens by setting XDG_CACHE_HOME
to a temporary directory in tests.constants
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the tutorials I have to remove these data too. There it would be easier to remove only the MSUI_CONFIG_PATH, which I can do by using a config, which I also clear.
The cache should behave in a way that it doesn't matter if it exists already or not (just speeding things up if it does), so there should not necessarily be a need to remove it. Nonetheless, the tutorials could also just set XDG_CACHE_HOME (or a MSUI_CACHE_PATH, if we want to additionally introduce that).
Because it wasn't the same dir on a new tutorial I didn't care.
It still left trash in /tmp though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on my KDE that is empty.
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html:
$XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will see next days when I recreate the tutorials if we have to adopt something.
Purpose of PR?:
Fix osfs:/ directory leftover in CWD after tests
Fix leftover directories in /tmp after tests
The way wms_cache was set previously made it so that after each tests
run there would be one or more directories leftover in /tmp. This also
happened for each start of MSUI. This change makes MSUI use the
platform-specific cache directory of the user instead and sets
XDG_CACHE_HOME to isolate those between test runs.
Fixes #2148.
Does this PR introduce a breaking change?
If the changes in this PR are manually verified, list down the scenarios covered::
Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs
Does this PR results in some Documentation changes?
If yes, include the list of Documentation changes
Checklist:
<type>: <subject>