fix broken logs

This commit is contained in:
j 2019-02-23 12:50:35 +05:30
parent 08a3477e88
commit b3246f05db
2 changed files with 15 additions and 1 deletions

View file

@ -95,4 +95,4 @@ FULLTEXT_SUPPORT = fulltext.platform_supported()
if not FULLTEXT_SUPPORT:
config['itemKeys'] = [k for k in config['itemKeys'] if k['id'] != 'fulltext']
DB_VERSION = 18
DB_VERSION = 19

View file

@ -379,6 +379,8 @@ class Update(Thread):
db_version = migrate_17()
if db_version < 18:
db_version = migrate_18()
if db_version < 19:
db_version = migrate_19()
settings.server['db_version'] = db_version
def run(self):
@ -698,3 +700,15 @@ def migrate_18():
'CREATE INDEX ix_annotation_findnotes ON annotation (findnotes)'
])
return 18
def migrate_19():
from user.models import User
with db.session():
peers = [u for u in User.query.filter_by(peered=True)]
peers.sort(key=lambda u: utils.user_sort_key(u.json()))
for u in peers:
peer = utils.get_peer(u.id)
if not peer.info.get('revision') and os.path.exists(peer._logpath) and os.path.getsize(peer._logpath):
logger.debug('try to apply pending logs for %s', u.id)
peer.apply_log()
return 19