db: Occasionally optimize the database
I do this whenever we commit during scanning, and during application shutdown. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
853594fc26
commit
a85ac03517
|
@ -9,3 +9,7 @@ Connection.row_factory = sqlite3.Row
|
|||
|
||||
commit = Connection.commit
|
||||
execute = Connection.execute
|
||||
|
||||
def optimize():
|
||||
Connection.execute("PRAGMA analysis_limit=1000")
|
||||
Connection.execute("PRAGMA optimize")
|
||||
|
|
|
@ -9,7 +9,9 @@ class Task(GObject.GObject):
|
|||
|
||||
|
||||
class CommitTask(Task):
|
||||
def run_task(self): db.sql.commit()
|
||||
def run_task(self):
|
||||
db.sql.commit()
|
||||
db.sql.optimize()
|
||||
|
||||
|
||||
class FileTask(Task):
|
||||
|
|
|
@ -3,6 +3,7 @@ from . import icons
|
|||
from . import window
|
||||
from gi.repository import Gtk
|
||||
import audio
|
||||
import db
|
||||
|
||||
class EmmentalApplication(Gtk.Application):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -16,4 +17,8 @@ class EmmentalApplication(Gtk.Application):
|
|||
Gtk.Application.do_startup(self)
|
||||
self.add_window(self.window)
|
||||
|
||||
def do_shutdown(self):
|
||||
db.sql.optimize()
|
||||
Gtk.Application.do_shutdown(self)
|
||||
|
||||
Application = EmmentalApplication()
|
||||
|
|
Loading…
Reference in New Issue