mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
WAL truncating #769
This commit is contained in:
@@ -40,7 +40,9 @@
|
|||||||
// Size and last mod of DB ------------------------------------------------------
|
// Size and last mod of DB ------------------------------------------------------
|
||||||
|
|
||||||
$nax_db = str_replace('front', 'db', getcwd()).'/app.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_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));
|
$nax_db_mod = date ("F d Y H:i:s", filemtime($nax_db));
|
||||||
|
|
||||||
|
|
||||||
@@ -104,13 +106,13 @@ $db->close();
|
|||||||
<div class="db_info_table_row">
|
<div class="db_info_table_row">
|
||||||
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_database_path');?></div>
|
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_database_path');?></div>
|
||||||
<div class="db_info_table_cell">
|
<div class="db_info_table_cell">
|
||||||
<?php echo $nax_db;?>
|
<?php echo $nax_db;?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="db_info_table_row">
|
<div class="db_info_table_row">
|
||||||
<div class="db_info_table_cell"><?= lang('Maintenance_database_size');?></div>
|
<div class="db_info_table_cell"><?= lang('Maintenance_database_size');?></div>
|
||||||
<div class="db_info_table_cell">
|
<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>
|
</div>
|
||||||
<div class="db_info_table_row">
|
<div class="db_info_table_row">
|
||||||
|
|||||||
@@ -204,13 +204,18 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
|||||||
|
|
||||||
conn.commit()
|
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
|
# Shrink DB
|
||||||
mylog('verbose', [f'[{pluginName}] Shrink Database'])
|
mylog('verbose', [f'[{pluginName}] Shrink Database'])
|
||||||
cursor.execute ("VACUUM;")
|
cursor.execute ("VACUUM;")
|
||||||
|
|
||||||
# Close the database connection
|
# Close the database connection
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def handleEmpty(input):
|
|||||||
return 'null'
|
return 'null'
|
||||||
else:
|
else:
|
||||||
# Validate and sanitize message content
|
# Validate and sanitize message content
|
||||||
# Remove potentially problematic characters if string
|
# Remove potentially problematic characters in string
|
||||||
if isinstance(input, str):
|
if isinstance(input, str):
|
||||||
input = re.sub(r'[^\x00-\x7F]+', ' ', input)
|
input = re.sub(r'[^\x00-\x7F]+', ' ', input)
|
||||||
input = input.replace('\n', '') # Removing new lines
|
input = input.replace('\n', '') # Removing new lines
|
||||||
|
|||||||
+1
-6
@@ -182,7 +182,7 @@ def main ():
|
|||||||
mylog('verbose', ['[Notification] No changes to report'])
|
mylog('verbose', ['[Notification] No changes to report'])
|
||||||
|
|
||||||
# Commit SQL
|
# Commit SQL
|
||||||
db.commitDB()
|
db.commitDB()
|
||||||
|
|
||||||
# Footer
|
# Footer
|
||||||
|
|
||||||
@@ -198,11 +198,6 @@ def main ():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# BEGIN
|
# BEGIN
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user