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)