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,6 +191,12 @@ class UploadHandler(tornado.web.RequestHandler):
file.move() file.move()
else: else:
user = state.user() user = state.user()
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 item = file.item
if user not in item.users: if user not in item.users:
logger.debug('add %s to local user', id) logger.debug('add %s to local user', id)