work around broken db

This commit is contained in:
j 2019-01-14 18:05:51 +05:30
parent 7d0d473acd
commit 3d882425e4

View file

@ -191,7 +191,13 @@ class UploadHandler(tornado.web.RequestHandler):
file.move()
else:
user = state.user()
item = file.item
if not file.item:
item = Item.get_or_create(id=file.sha1, info=file.info)
file.item_id = item.id
state.db.session.add(file)
state.db.session.commit()
else:
item = file.item
if user not in item.users:
logger.debug('add %s to local user', id)
item.add_user(user)