get pages from file if no longer in item.info
This commit is contained in:
parent
9f3374a7dc
commit
200c6df686
2 changed files with 24 additions and 1 deletions
|
@ -101,4 +101,4 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
|
|||
|
||||
DEBUG_HTTP = server.get('debug_http', False)
|
||||
|
||||
DB_VERSION = 2
|
||||
DB_VERSION = 3
|
||||
|
|
|
@ -299,6 +299,8 @@ class Update(Thread):
|
|||
db_version = migrate_1()
|
||||
if db_version < 2:
|
||||
db_version = migrate_2()
|
||||
if db_version < 3:
|
||||
db_version = migrate_3()
|
||||
settings.server['db_version'] = settings.DB_VERSION
|
||||
|
||||
def run(self):
|
||||
|
@ -332,3 +334,24 @@ def migrate_2():
|
|||
s.item.update_sort()
|
||||
session.commit()
|
||||
return 2
|
||||
|
||||
def migrate_3():
|
||||
with db.session():
|
||||
import item.models
|
||||
for i in item.models.Item.find({
|
||||
'query': {
|
||||
'conditions': [{
|
||||
'key':'mediastate',
|
||||
'value':'available',
|
||||
'operator': '=='
|
||||
}]
|
||||
}
|
||||
}):
|
||||
if not i.files.all():
|
||||
i.remove_file()
|
||||
else:
|
||||
f = i.files.all()[0]
|
||||
if not 'pages' in i.info and 'pages' in f.info:
|
||||
i.info['pages'] = f.info['pages']
|
||||
i.save()
|
||||
return 3
|
||||
|
|
Loading…
Reference in a new issue