From 0afdaddd0a20200ab61dd318194ee125dc04732c Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Mon, 26 Aug 2013 18:59:00 -0700 Subject: [PATCH] Create index on hash --- src/bitrot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitrot.py b/src/bitrot.py index 97fe219..00728c3 100644 --- a/src/bitrot.py +++ b/src/bitrot.py @@ -70,12 +70,12 @@ def get_sqlite3_cursor(path, copy=False): conn = sqlite3.connect(path) atexit.register(conn.close) cur = conn.cursor() - for name, in cur.execute('SELECT name FROM sqlite_master'): - if name == 'bitrot': - break - else: + names = set(name for name, in cur.execute('SELECT name FROM sqlite_master')) + if 'bitrot' not in names: cur.execute('CREATE TABLE bitrot (path TEXT PRIMARY KEY, ' 'mtime INTEGER, hash TEXT, timestamp TEXT)') + if 'bitrot_hash_idx' not in names: + cur.execute('CREATE INDEX bitrot_hash_idx ON bitrot (hash)') return conn