diff --git a/oml/item/api.py b/oml/item/api.py index 4493233..0fd7a6a 100644 --- a/oml/item/api.py +++ b/oml/item/api.py @@ -168,7 +168,6 @@ def remove(data): ''' if 'ids' in data and data['ids']: for i in models.Item.query.filter(models.Item.id.in_(data['ids'])): - logger.info('remove item %s', i) i.remove_file() state.cache.clear('group:') return { diff --git a/oml/item/handlers.py b/oml/item/handlers.py index 36ca61a..aabeff2 100644 --- a/oml/item/handlers.py +++ b/oml/item/handlers.py @@ -172,8 +172,7 @@ class UploadHandler(tornado.web.RequestHandler): id = get_id(data=upload.body) ids.append(id) file = File.get(id) - if not file or not os.path.exists(file.fullpath()): - logger.debug('add %s to library', id) + if not file: prefix_books = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books' + os.sep) prefix_imported = os.path.join(prefix_books, '.import' + os.sep) ox.makedirs(prefix_imported) @@ -191,13 +190,7 @@ class UploadHandler(tornado.web.RequestHandler): file.move() else: user = state.user() - item = file.item - if user not in item.users: - logger.debug('add %s to local user', id) - item.add_user(user) - add_record('additem', item.id, file.info) - add_record('edititem', item.id, item.meta) - item.update() + file.item.add_user(user) if listname and ids: l = List.get(settings.USER_ID, listname) if l: diff --git a/oml/item/models.py b/oml/item/models.py index 9448260..27e4191 100644 --- a/oml/item/models.py +++ b/oml/item/models.py @@ -800,7 +800,6 @@ class File(db.Model): if os.path.exists(path) and os.path.exists(current_path): os.unlink(path) return - logger.debug('mv "%s" "%s"', self.path, new_path) self.path = new_path self.save() for folder in set(os.path.dirname(p) for p in [current_path, path]): diff --git a/oml/item/scan.py b/oml/item/scan.py index aa96bdc..d9c4bb1 100644 --- a/oml/item/scan.py +++ b/oml/item/scan.py @@ -7,7 +7,6 @@ import os import shutil import stat import time -import unicodedata import ox @@ -32,7 +31,6 @@ def remove_missing(books=None): prefix = get_prefix() if books is None: books = collect_books(prefix) - books = [unicodedata.normalize('NFD', path) for path in books] with db.session(): if os.path.exists(prefix): logger.debug('scan for removed files') @@ -42,7 +40,6 @@ def remove_missing(books=None): if state.shutdown: return path = f.fullpath() - path = unicodedata.normalize('NFD', path) db_paths.append(path) if f.item: items[path] = f.sha1 @@ -175,6 +172,7 @@ def run_scan(): elif user not in file.item.users: item = file.item item.add_user(user) + logger.debug('add %s to local user', id) add_record('additem', item.id, file.info) add_record('edititem', item.id, item.meta) @@ -196,10 +194,11 @@ def run_scan(): library_items = set([str(i) for i in user.library.items]) gone = library_items - ids if gone: + logger.debug('cleaning up %s deleted records', len(gone)) for id in gone: i = Item.get(id) path = i.get_path() - if not path or not os.path.exists(path): + if path and not os.path.exists(path): logger.debug('cleaning orphaned record %s %s', i, path) i.remove_file() missing = ids - library_items diff --git a/oml/library.py b/oml/library.py index 54902d1..d61398f 100644 --- a/oml/library.py +++ b/oml/library.py @@ -288,7 +288,7 @@ class Peer(object): l.remove_items(lremove, commit=False) if ladd or lremove: logger.debug('update list %s', l.name) - elif self.info['lists'][l.name]: + else: l.add_items(self.info['lists'][l.name], commit=False) update_items = list(set(update_items) - set(self.info['lists'][l.name])) logger.debug('update list %s', l.name) diff --git a/static/js/utils.js b/static/js/utils.js index 388c453..fc7186f 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1028,7 +1028,7 @@ oml.updateDebugMenu = function() { oml.user.ui.showDebugMenu ? menu.show() : menu.hide(); }; -oml.supportedExtensions = ['pdf', 'epub', 'kepub', 'cbr', 'cbz', 'txt']; +oml.supportedExtensions = ['pdf', 'epub', 'kepub', 'cbr', 'cbz']; oml.upload = function(fileslist, callback) { var files = [], ids = [];