From: Oleg Broytman Date: Sun, 5 Mar 2006 20:30:45 +0000 (+0000) Subject: Remove old filenames at the start. X-Git-Tag: v4.0.0~60 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=18feed9f91cc816eac670351c71a930fd13ec211;p=xsetbg.git Remove old filenames at the start. git-svn-id: file:///home/phd/archive/SVN/xsetbg/trunk@8 143022c7-580b-0410-bae3-87f2bf5d3141 --- diff --git a/xsetbg.py b/xsetbg.py index 93791a4..865a5ee 100755 --- a/xsetbg.py +++ b/xsetbg.py @@ -123,7 +123,18 @@ except anydbm.error, msg: os.remove(global_db_name) global_db = shelve.open(global_db_name, flag='c') -global_db.close() # Close DB in parent process +# Remove old filenames +old_time = time() - min_delay + +to_delete = [] +for key in global_db.keys(): + if key.startswith('/') and global_db[key] < old_time: + to_delete.append(key) + +for key in to_delete: + del global_db[key] + +global_db.close() # Close DB in the parent process # DB keys