Linux: Cleaners do not obey XDG base directory specification

Bug #1222525 reported by Alexander Schlarb
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BleachBit
Fix Released
Medium
Unassigned

Bug Description

The directories ~/.local/share, ~/.config and ~/.cache are part of the XDG Base Directory Specification[¹]. Currently cleaners reference them directly which is prohibited by the spec!

Instead one has to first check if an environment variable is set (there is one for each of them) and only fall back to these directories if no corresponding environment variable has been found.

Step 1:
Basically BleachBit should provide these directories as variables instead of forcing cleaners to hard-code the default values:
Replace "$XDG_DATA_HOME" with os.environ.get("XDG_DATA_HOME", os.path.expanduser("~/.local/share")) in all cleaner paths
Replace "$XDG_CONFIG_HOME" with os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) in all cleaner paths
Replace "$XDG_CACHE_HOME" with os.environ.get("XDG_CACHE_HOME", os.path.expanduser("~/.cache")) in all cleaner paths

Step 2:
Replace the current hard-coded defaults with theses variable names in all current CleanerML files.

Step 3:
Add information about this to the Wiki-Page so that people writing new cleaners know about this.

Affects: Linux (all distributions); All cleaners for applications already implementing this specification

[¹]http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

Revision history for this message
Alexander Schlarb (alexander255) wrote :
Revision history for this message
Alexander Schlarb (alexander255) wrote :

The fix for step two was to execute the following commands in the bleachbit-code/cleaners directory:
sed -i 's/~\/.config/$XDG_CONFIG_HOME/g' *
sed -i 's/~\/.cache/$XDG_CACHE_HOME/g' *
sed -i 's/~\/.local\/share/$XDG_DATA_HOME/g' *

This should probably also be done with the cleanerml git repository.

Andrew Ziem (ahziem1)
Changed in bleachbit:
milestone: none → 1.10
Andrew Ziem (ahziem1)
Changed in bleachbit:
milestone: 1.10 → 1.12
Changed in bleachbit:
importance: Undecided → Medium
Revision history for this message
Andrew Ziem (ahziem1) wrote :

There are already many fixes ready for BleachBit version 1.12, so I would like to not delay releasing what is ready. This change would require testing on a variety of systems to ensure there are no regressions.

Changed in bleachbit:
milestone: 1.12 → 1.14
Andrew Ziem (ahziem1)
Changed in bleachbit:
assignee: nobody → Andrew Ziem (ahziem1)
status: New → In Progress
Revision history for this message
Andrew Ziem (ahziem1) wrote :

Fixed in Git commit 0eb233ad554ce18900ff71eb71efa1fb33e0d02b

Thanks!

Changed in bleachbit:
assignee: Andrew Ziem (ahziem1) → nobody
status: In Progress → Fix Committed
Revision history for this message
Andrew Ziem (ahziem1) wrote :

By the way, I changed the Python implementation to be faster. It initializes only once for each time the application starts

Andrew Ziem (ahziem1)
Changed in bleachbit:
status: Fix Committed → In Progress
Andrew Ziem (ahziem1)
Changed in bleachbit:
status: In Progress → Fix Committed
Revision history for this message
Andrew Ziem (ahziem1) wrote :

This fix was released in BleachBit 1.19 beta

https://www.bleachbit.org/news/bleachbit-119-beta

I look forward to hearing how this works for you

Changed in bleachbit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.