summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsqlite-vacuum.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/sqlite-vacuum.py b/sqlite-vacuum.py
new file mode 100755
index 0000000..03b610a
--- /dev/null
+++ b/sqlite-vacuum.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+import os.path
+
+import magic
+import sqlite3
+
+home = os.path.expanduser('~')
+
+try:
+ m = magic.open(magic.MAGIC_NONE)
+ m.load()
+
+ for root, dirs, files in os.walk(os.path.join(home, '.config', 'chromium')):
+ for f in files:
+ path = os.path.join(root, f)
+ magic_type = m.file(path)
+ if magic_type and 'SQLite' in magic_type:
+ try:
+ c = sqlite3.connect(path)
+ c.execute('VACUUM')
+ c.execute('REINDEX')
+ finally:
+ c.close()
+finally:
+ m.close()