more cleanup fallbacks
This commit is contained in:
parent
709e067e14
commit
3a1b3a5c3c
2 changed files with 10 additions and 3 deletions
|
@ -172,7 +172,8 @@ class UploadHandler(tornado.web.RequestHandler):
|
|||
id = get_id(data=upload.body)
|
||||
ids.append(id)
|
||||
file = File.get(id)
|
||||
if not file:
|
||||
if not file or not os.path.exists(file.fullpath()):
|
||||
logger.debug('add %s to library', id)
|
||||
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)
|
||||
|
@ -190,7 +191,13 @@ class UploadHandler(tornado.web.RequestHandler):
|
|||
file.move()
|
||||
else:
|
||||
user = state.user()
|
||||
file.item.add_user(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()
|
||||
if listname and ids:
|
||||
l = List.get(settings.USER_ID, listname)
|
||||
if l:
|
||||
|
|
|
@ -198,7 +198,7 @@ def run_scan():
|
|||
for id in gone:
|
||||
i = Item.get(id)
|
||||
path = i.get_path()
|
||||
if path and not os.path.exists(path):
|
||||
if not path or not os.path.exists(path):
|
||||
logger.debug('cleaning orphaned record %s %s', i, path)
|
||||
i.remove_file()
|
||||
missing = ids - library_items
|
||||
|
|
Loading…
Reference in a new issue