diff --git a/couchpotato/core/database.py b/couchpotato/core/database.py index e65e0de..1848867 100644 --- a/couchpotato/core/database.py +++ b/couchpotato/core/database.py @@ -21,6 +21,8 @@ class Database(object): def __init__(self): addApiView('database.list_documents', self.listDocuments) + addApiView('database.reindex', self.reindex) + addApiView('database.compact', self.compact) addApiView('database.document.update', self.updateDocument) addApiView('database.document.delete', self.deleteDocument) @@ -117,6 +119,34 @@ class Database(object): return results + def reindex(self, **kwargs): + + success = True + try: + db = self.getDB() + db.reindex() + except: + log.error('Failed index: %s', traceback.format_exc()) + success = False + + return { + 'success': success + } + + def compact(self, **kwargs): + + success = True + try: + db = self.getDB() + db.compact() + except: + log.error('Failed compact: %s', traceback.format_exc()) + success = False + + return { + 'success': success + } + def migrate(self): from couchpotato import Env