mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
WAL truncating #769
This commit is contained in:
@@ -40,7 +40,9 @@
|
||||
// Size and last mod of DB ------------------------------------------------------
|
||||
|
||||
$nax_db = str_replace('front', 'db', getcwd()).'/app.db';
|
||||
$nax_wal = str_replace('front', 'db', getcwd()).'/app.db-wal';
|
||||
$nax_db_size = number_format((filesize($nax_db) / 1000000),2,",",".") . ' MB';
|
||||
$nax_wal_size = number_format((filesize($nax_wal) / 1000000),2,",",".") . ' MB';
|
||||
$nax_db_mod = date ("F d Y H:i:s", filemtime($nax_db));
|
||||
|
||||
|
||||
@@ -110,7 +112,7 @@ $db->close();
|
||||
<div class="db_info_table_row">
|
||||
<div class="db_info_table_cell"><?= lang('Maintenance_database_size');?></div>
|
||||
<div class="db_info_table_cell">
|
||||
<?php echo $nax_db_size;?>
|
||||
<?php echo $nax_db_size;?> (wal: <?php echo $nax_wal_size;?>)
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_info_table_row">
|
||||
|
||||
@@ -204,6 +204,12 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
|
||||
conn.commit()
|
||||
|
||||
# Check WAL file size
|
||||
cursor.execute("PRAGMA wal_checkpoint(TRUNCATE);")
|
||||
cursor.execute("PRAGMA wal_checkpoint(FULL);")
|
||||
|
||||
mylog('verbose', [f'[{pluginName}] WAL checkpoint executed to truncate file.'])
|
||||
|
||||
# Shrink DB
|
||||
mylog('verbose', [f'[{pluginName}] Shrink Database'])
|
||||
cursor.execute ("VACUUM;")
|
||||
@@ -212,7 +218,6 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
conn.close()
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# BEGIN
|
||||
#===============================================================================
|
||||
|
||||
@@ -44,7 +44,7 @@ def handleEmpty(input):
|
||||
return 'null'
|
||||
else:
|
||||
# Validate and sanitize message content
|
||||
# Remove potentially problematic characters if string
|
||||
# Remove potentially problematic characters in string
|
||||
if isinstance(input, str):
|
||||
input = re.sub(r'[^\x00-\x7F]+', ' ', input)
|
||||
input = input.replace('\n', '') # Removing new lines
|
||||
|
||||
@@ -198,11 +198,6 @@ def main ():
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# BEGIN
|
||||
#===============================================================================
|
||||
|
||||
Reference in New Issue
Block a user