Fixed #1070 (Clear search index for deletedb and syncdb command)

This commit is contained in:
Emanuel Schuetze 2013-11-14 22:47:34 +01:00
parent 89c7bd1277
commit 85fc09036f

View File

@ -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)