extract tableofcontents from existing pdfs
This commit is contained in:
parent
de984a344e
commit
e3f0064157
1 changed files with 19 additions and 1 deletions
20
oml/setup.py
20
oml/setup.py
|
@ -180,6 +180,10 @@ PRAGMA journal_mode=WAL
|
|||
create_default_lists()
|
||||
|
||||
def upgrade_db(old, new=None):
|
||||
|
||||
def run_after(v):
|
||||
return old <= v and new > v
|
||||
|
||||
if new:
|
||||
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
|
||||
with db.session():
|
||||
|
@ -330,7 +334,7 @@ def upgrade_db(old, new=None):
|
|||
if u.id != settings.USER_ID:
|
||||
Metadata.get_or_create(u.id, i.id, i.meta, False)
|
||||
session.commit()
|
||||
if old <= '20160111-617-206e39c' and new > '20160111-617-206e39c':
|
||||
if run_after('20160111-617-206e39c'):
|
||||
from item.models import File
|
||||
import media
|
||||
with db.session() as session:
|
||||
|
@ -344,6 +348,20 @@ def upgrade_db(old, new=None):
|
|||
session.add(f.item)
|
||||
session.add(f)
|
||||
session.commit()
|
||||
if run_after('20160112-651-de984a3'):
|
||||
from item.models import File
|
||||
import media
|
||||
with db.session() as session:
|
||||
for f in File.query:
|
||||
if f.info.get('extension') == 'pdf':
|
||||
if not 'tableofcontents' in f.item.meta:
|
||||
f.info = media.metadata(f.fullpath())
|
||||
if 'tableofcontents' in f.info:
|
||||
f.item.meta['tableofcontents'] = f.info['tableofcontents']
|
||||
f.item.update()
|
||||
session.add(f.item)
|
||||
session.add(f)
|
||||
session.commit()
|
||||
|
||||
if old <= '20140527-120-3cb9819':
|
||||
run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')
|
||||
|
|
Loading…
Reference in a new issue