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 socket
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
import string
import subprocess
@@ -925,7 +925,14 @@ def init_datastructs(f):
cache = TagCache.load(cachefname)

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:
if cache.modified:
cache.store(cachefname)


Loading…
Cancel
Save