summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Hajdan, Jr <phajdan.jr@gentoo.org>2012-06-18 09:37:23 +0200
committerPawel Hajdan, Jr <phajdan.jr@gentoo.org>2012-06-18 09:37:23 +0200
commit31e12833015525826359340f568b2b6fad783203 (patch)
tree09ba646d7625cf77b3f772022dfeadfab39c3110
parentdelete unused files (diff)
downloadchromium-tools-31e12833015525826359340f568b2b6fad783203.tar.gz
chromium-tools-31e12833015525826359340f568b2b6fad783203.tar.bz2
chromium-tools-31e12833015525826359340f568b2b6fad783203.zip
Add sqlite-vacuum script, bug #413295.
-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()