Add an option to the "delete" action of CleanerML to ensure files are not in use before removing them

Bug #1438908 reported by Aurélien Gâteau
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BleachBit
Invalid
Undecided
Unassigned

Bug Description

Some files should not be deleted, or even worse shredded, if they are being used by other programs, a common example is KDE icon caches, which are mmap-ed by several processes. This causes many bug reports of users suddenly getting his window manager and all its applications to crash after running BleachBit. See https://bugs.kde.org/show_bug.cgi?id=254741 , look at the number of duplicates.

I think it would help to be able to mark actions like '<action command="delete" search="glob" path="~/.kde/cache-*/*/*"/>' with a flag to prevent erasing or shredding files if there are process using the files. The check could do something similar to what lsof does.

I put together a quick script based on lsof: https://gist.github.com/agateau/1cec7aba565694e80899 . Running it in one of my ~/kde/cache-* dirs outputs the following:

"""
# Can be removed

bookmarkrunnerfirefoxdbfile.sqlite
bookmarkrunnerfirefoxdbfile.sqlite-shm
bookmarkrunnerfirefoxdbfile.sqlite-wal
choqok-userimages.kcache
kdenlive-thumbs.kcache
ksycoca4stamp
plasma-svgelements-Dynamo Plasma_v1.0
plasma-svgelements-default_v2.0
plasma-svgelements-internal-system-colors
plasma-svgelements-muon-contenttheme_v0.1
plasma_theme_default_v2.0.kcache
plasma_theme_muon-contenttheme_v0.1.kcache

# Don't touch!

icon-cache.kcache
ksycoca4
plasma_theme_Dynamo Plasma_v1.0.kcache
plasma_theme_internal-system-colors.kcache
"""

Having a similar check in BleachBit would be great.

Revision history for this message
Andrew Ziem (ahziem1) wrote :

This is a good idea. For cleaning /tmp/ some files, including some specific to KDE, are whitelisted, but your approach is more general.

To avoid the performance penalty, the flag you suggest would usually be disabled.

My main concern then is if there are any exceptions. Have you tried deleting the KDE cache files based on "lsof" and checking for negative side effects?

Changed in bleachbit:
milestone: none → 2.0
Revision history for this message
Martin Gräßlin (ubuntu-martin-graesslin) wrote :

For your information: the current behavior of deleting without checking will have horrible results once the wayland transition is completed. If KWin crashes it will take the complete session with it including the running bleachbit instance.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> For cleaning /tmp/ some files, including some specific to KDE, are whitelisted

I am curious about this whitelist: there is nothing which looks like a whitelist in https://github.com/az0/bleachbit/blob/master/cleaners/kde.xml . Is it somewhere else?

> Have you tried deleting the KDE cache files based on "lsof" and checking for negative side effects?

Do you mean removing the files for which lsof did not find any user? I just did so. So far so good, KWin and Plasma are still working, running KDE applications did not go away and I can start new KDE applications.

Revision history for this message
Andrew Ziem (ahziem1) wrote :

The current whitelist in BleachBit 1.7 is not for kde.xml, not for ~/.cache, and not for CleanerML. It is here for cleaning /tmp in the "System - Temporary Files" cleaner
https://github.com/az0/bleachbit/blob/ca3cc1350695c8ac23681ca4a23e768a972fe81b/bleachbit/Cleaner.py#L785

Martin: until I can fix this properly, how about I add a warning to kde.xml like this?
<warning>Do not use with Wayland, which will crash.</warning>

Aurélien: Yes, that is the test I meant. I am glad it seems to be working reliably.

Revision history for this message
Martin Gräßlin (ubuntu-martin-graesslin) wrote :

I don't think that such a warning will help anything, as:
a) our users hopefully do not know what Wayland is and whether they are using it
b) I saw relevant KDE files marked as to be deleted under System

Changed in bleachbit:
importance: Undecided → Wishlist
Revision history for this message
Andrew Ziem (ahziem1) wrote :

Sorry for the slow response. If this still exists in the latest version (BleachBit 2.1), please file bug report in the new home: https://github.com/bleachbit/bleachbit/blob/master/CONTRIBUTING.md . If this bug no longer exists, it would be nice if you wrote a note to confirm.

Changed in bleachbit:
importance: Wishlist → Undecided
milestone: 2.2 → none
status: New → Invalid
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.