1 |
commit: 31e12833015525826359340f568b2b6fad783203 |
2 |
Author: Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jun 18 07:37:23 2012 +0000 |
4 |
Commit: Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jun 18 07:37:23 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/chromium-tools.git;a=commit;h=31e12833 |
7 |
|
8 |
Add sqlite-vacuum script, bug #413295. |
9 |
|
10 |
--- |
11 |
sqlite-vacuum.py | 26 ++++++++++++++++++++++++++ |
12 |
1 files changed, 26 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/sqlite-vacuum.py b/sqlite-vacuum.py |
15 |
new file mode 100755 |
16 |
index 0000000..03b610a |
17 |
--- /dev/null |
18 |
+++ b/sqlite-vacuum.py |
19 |
@@ -0,0 +1,26 @@ |
20 |
+#!/usr/bin/env python |
21 |
+ |
22 |
+import os.path |
23 |
+ |
24 |
+import magic |
25 |
+import sqlite3 |
26 |
+ |
27 |
+home = os.path.expanduser('~') |
28 |
+ |
29 |
+try: |
30 |
+ m = magic.open(magic.MAGIC_NONE) |
31 |
+ m.load() |
32 |
+ |
33 |
+ for root, dirs, files in os.walk(os.path.join(home, '.config', 'chromium')): |
34 |
+ for f in files: |
35 |
+ path = os.path.join(root, f) |
36 |
+ magic_type = m.file(path) |
37 |
+ if magic_type and 'SQLite' in magic_type: |
38 |
+ try: |
39 |
+ c = sqlite3.connect(path) |
40 |
+ c.execute('VACUUM') |
41 |
+ c.execute('REINDEX') |
42 |
+ finally: |
43 |
+ c.close() |
44 |
+finally: |
45 |
+ m.close() |