Browse Source

on each successfull exit, do a little db maintainance...

main
John-Mark Gurney 1 year ago
parent
commit
d14fb005bb
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      ui/medashare/cli.py

+ 9
- 2
ui/medashare/cli.py View File

@@ -57,7 +57,7 @@ import re
import shutil import shutil
import socket import socket
import sqlalchemy import sqlalchemy
from sqlalchemy import create_engine, select, insert, func, delete
from sqlalchemy import create_engine, select, insert, func, delete, text
from sqlalchemy.orm import sessionmaker, aliased, load_only from sqlalchemy.orm import sessionmaker, aliased, load_only
import string import string
import subprocess import subprocess
@@ -925,7 +925,14 @@ def init_datastructs(f):
cache = TagCache.load(cachefname) cache = TagCache.load(cachefname)


try: try:
return f(options, persona, objstr, cache)
r = f(options, persona, objstr, cache)

# per: https://www.sqlite.org/lang_analyze.html
with engine.connect() as con:
con.execute(text('PRAGMA analysis_limit = 400;'))
con.execute(text('PRAGMA optimize;'))
con.commit()
return r
finally: finally:
if cache.modified: if cache.modified:
cache.store(cachefname) cache.store(cachefname)


Loading…
Cancel
Save