From 85fc09036f9655c95f25b1913e708dad07ca35e4 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 14 Nov 2013 22:47:34 +0100 Subject: [PATCH] Fixed #1070 (Clear search index for deletedb and syncdb command) --- openslides/__main__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openslides/__main__.py b/openslides/__main__.py index 7e6ce62a3..d9ac91d9e 100644 --- a/openslides/__main__.py +++ b/openslides/__main__.py @@ -242,9 +242,13 @@ def syncdb(settings, args): """ ensure_settings(settings, args) # TODO: Check use of filesystem2unicode here. - path = filesystem2unicode(os.path.dirname(get_database_path_from_settings())) - if not os.path.exists(path): - os.makedirs(path) + db_file = get_database_path_from_settings() + db_dir = filesystem2unicode(os.path.dirname(db_file)) + if not os.path.exists(db_dir): + os.makedirs(db_dir) + if not os.path.exists(db_file): + print('Clearing old search index...') + execute_from_command_line(["", "clear_index", "--noinput"]) execute_from_command_line(["", "syncdb", "--noinput"]) return 0 @@ -308,6 +312,8 @@ def deletedb(settings, args): if database_path and os.path.exists(database_path): os.remove(database_path) print('SQLite3 database file %s successfully deleted.' % database_path) + execute_from_command_line(["", "clear_index", "--noinput"]) + print('Whoosh search index successfully cleared.') return_value = 0 else: print('SQLite3 database file %s does not exist.' % database_path)