mirror of
https://github.com/anxdpanic/plugin.video.youtube.git
synced 2025-12-06 02:30:50 -08:00
Prune invalid entries from DB when closing connection #1331
This commit is contained in:
parent
a8fa1606cb
commit
bbc2411130
1 changed files with 7 additions and 0 deletions
|
|
@ -185,6 +185,11 @@ class Storage(object):
|
||||||
' ) <= {{0}}'
|
' ) <= {{0}}'
|
||||||
' );'
|
' );'
|
||||||
),
|
),
|
||||||
|
'prune_invalid': (
|
||||||
|
'DELETE'
|
||||||
|
' FROM {table}'
|
||||||
|
' WHERE key IS NULL;'
|
||||||
|
),
|
||||||
'refresh': (
|
'refresh': (
|
||||||
'UPDATE'
|
'UPDATE'
|
||||||
' {table}'
|
' {table}'
|
||||||
|
|
@ -402,6 +407,7 @@ class Storage(object):
|
||||||
elif self._close_actions:
|
elif self._close_actions:
|
||||||
queries = (
|
queries = (
|
||||||
'BEGIN IMMEDIATE;',
|
'BEGIN IMMEDIATE;',
|
||||||
|
self._sql['prune_invalid'],
|
||||||
self._set_many(items=None, defer=True, flush=True),
|
self._set_many(items=None, defer=True, flush=True),
|
||||||
self._optimize_item_count(defer=True),
|
self._optimize_item_count(defer=True),
|
||||||
self._optimize_file_size(defer=True),
|
self._optimize_file_size(defer=True),
|
||||||
|
|
@ -412,6 +418,7 @@ class Storage(object):
|
||||||
else:
|
else:
|
||||||
queries = (
|
queries = (
|
||||||
'BEGIN IMMEDIATE;',
|
'BEGIN IMMEDIATE;',
|
||||||
|
self._sql['prune_invalid'],
|
||||||
'COMMIT;',
|
'COMMIT;',
|
||||||
'VACUUM;',
|
'VACUUM;',
|
||||||
'PRAGMA optimize;',
|
'PRAGMA optimize;',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue