Merge pull request #1071 from emanuelschuetze/fix-1070

Fixed #1070 (Clear search index for deletedb and syncdb command)
This commit is contained in:
Oskar Hahn 2013-11-18 08:07:32 -08:00
commit ddffffd3a1

View File

@ -242,9 +242,13 @@ def syncdb(settings, args):
""" """
ensure_settings(settings, args) ensure_settings(settings, args)
# TODO: Check use of filesystem2unicode here. # TODO: Check use of filesystem2unicode here.
path = filesystem2unicode(os.path.dirname(get_database_path_from_settings())) db_file = get_database_path_from_settings()
if not os.path.exists(path): db_dir = filesystem2unicode(os.path.dirname(db_file))
os.makedirs(path) 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"]) execute_from_command_line(["", "syncdb", "--noinput"])
return 0 return 0
@ -308,6 +312,8 @@ def deletedb(settings, args):
if database_path and os.path.exists(database_path): if database_path and os.path.exists(database_path):
os.remove(database_path) os.remove(database_path)
print('SQLite3 database file %s successfully deleted.' % 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 return_value = 0
else: else:
print('SQLite3 database file %s does not exist.' % database_path) print('SQLite3 database file %s does not exist.' % database_path)