From a6e1bb9b4c45426f67c9d60485b360858e47f745 Mon Sep 17 00:00:00 2001 From: Marcus Linderoth Date: Sun, 10 Aug 2014 18:03:28 +0200 Subject: [PATCH] catch missing database file when running 'test' instead of crashing --- src/bitrot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bitrot.py b/src/bitrot.py index bfc5811..01f033e 100644 --- a/src/bitrot.py +++ b/src/bitrot.py @@ -94,7 +94,11 @@ def run(verbosity=1, test=False, follow_links=False, commit_interval=300, chunk_size=DEFAULT_CHUNK_SIZE): current_dir = b'.' # sic, relative path bitrot_db = os.path.join(current_dir, b'.bitrot.db') - conn = get_sqlite3_cursor(bitrot_db, copy=test) + try: + conn = get_sqlite3_cursor(bitrot_db, copy=test) + except ValueError: + print('No database exists so cannot test. Run the tool once first.') + sys.exit(2) cur = conn.cursor() new_paths = [] updated_paths = []