qutebrowser_configs/configs/atexit-cleanup.py

30 lines
1.0 KiB
Python
Raw Normal View History

2024-04-30 14:51:36 +00:00
# -*- mode: python; python-indent-offset: 4; tab-width: 0; encoding: utf-8-unix -*-
# This should be execed in config.py
import sys
import os
import atexit
@atexit.register
def atexit_cleanup():
lDels = [os.path.join(config.datadir, 'cookies'),
os.path.join(config.datadir, 'history.sqlite'),
]
bidir = os.path.join(config.datadir, 'webengine')
lDels += [os.path.join(bidir, 'Cookies'),
os.path.join(bidir, 'Cookies-journal'),
os.path.join(bidir, 'Favicons'),
os.path.join(bidir, 'Favicons-journal'),
os.path.join(bidir, 'History'),
os.path.join(bidir, 'History-journal'),
os.path.join(bidir, 'Network Persistent State'),
os.path.join(bidir, 'TransportSecurity'),
os.path.join(bidir, 'Visited Links'),
]
i = 0
for elt in lDels:
if os.path.exists(elt):
os.unlink(elt)
i += 1
sys.stderr.write(f"Cleaned up {i} files\n")