Please stop deleting whitelisted logs...

Forums: 

Hi.

Bleachbit does 'not' have a whitelist feature to prevent deletion of incorrectly determined 'rotated logs'.

Can I alter the Cleaner.py and/or the Unix.py to 'exclude' or 'whitelist' the log that Bleachbit is
accidentally delting?

/var/log/paco/paco-2.0.7

Thank you.

For BleachBit 0.7.4, you want to modify the function rotated_logs() in Unix.py which is here
http://bleachbit.svn.sourceforge.net/viewvc/bleachbit/trunk/bleachbit/Un...

Look at line 536

---
Andrew, lead developer

Hi.

In my version, 64 bit debian... 'Unix.py' contains the following for 'rotated_logs()'
What exactly do I change to disallow deleting /var/log/paco/paco-2.0.7
-------------------------------------------------------------------------------------------------------------------
def rotated_logs():
"""Yield a list of rotated (i.e., old) logs in /var/log/"""
# Ubuntu 9.04
# /var/log/dmesg.0
# /var/log/dmesg.1.gz
# Fedora 10
# /var/log/messages-20090118
globpaths = ( '/var/log/*.[0-9]', \
'/var/log/*/*.[0-9]', \
'/var/log/*.gz', \
'/var/log/*/*gz', \
'/var/log/*/*.old', \
'/var/log/*.old' )
for globpath in globpaths:
for path in glob.iglob(globpath):
yield path
regex = '-[0-9]{8}$'
globpaths = ( '/var/log/*-*', '/var/log/*/*-*' )
for path in FileUtilities.globex(globpaths, regex):
whitelist_re = '^/var/log/(removed_)?(packages|scripts)'
if None == re.match(whitelist_re, path): # for Slackware, Launchpad #367575
yield path

Replace whitelist_re = '^/var/log/(removed_)?(packages|scripts)' with
whitelist_re = '^/var/log/paco'

Then you can test it with a preview.

---
Andrew, lead developer

Sorry, your suggestion did not work.

Edited: /usr/share/bleachbit/bleachbit/Unix.py

for path in FileUtilities.globex(globpaths, regex):
whitelist_re = '^/var/log/paco'
if None == re.match(whitelist_re, path): # for Slackware, Launchpad #367575
yield path

Bleachbit Result;
Delete 4.1kB /var/log/paco/paco-2.0.7

Bleachbit is still deleting the log /var/log/paco/paco/paco-2.0.7

Could this be because there is no .log ending in the logfile /var/log/paco/paco-2.0.7 ?

Thank you.

Bleachbit still is deleting everything in the /var/logs/

Anyone have a solution, the whitelist suggestion did not work.

Thanks.
Justin

I see. The whitelist code needs to be a litle higher in his section

530 for globpath in globpaths:
531 for path in glob.iglob(globpath):
532 yield path

Replace line 532 with these three lines:

whitelist_re = '^/var/log/paco'
if None == re.match(whitelist_re, path):
yield path

Use proper indentation. (The third line is indented more than the first two.)

---
Andrew, lead developer

Thank you.

I tried following your instructions resulting in this - /usr/share/bleachbit/bleachbit/Unix.py
530 for globpath in globpaths:
531 for path in glob.iglob(globpath):
532 whitelist_re = '^/var/log/paco'
533 if None == re.match(whitelist_re, path):
534 yield path

FANTASTIC! It worked!

I would like to submit a feature request to offer a Whitelist option for those who wish to selectively ignore
files or directories from Bleachbit.

Thank you for a wonderful time saver.
Justin

The white list feature is on my short list, so I hope to add it "soon" (though I've been busy lately)

---
Andrew, lead developer

OK.

When the next version updates via apt-get dist-upgrade, will the custom Unix.py be overwritten with the new?

Regards.

Yes, I believe it will

---
Andrew, lead developer

BleachBit 0.8.0 is released with support for white listing files and folders

http://bleachbit.sourceforge.net/news/bleachbit-080-released

---
Andrew, lead developer