Add Purge Threshold

Adds a purge threshold setting. This setting allows the user to
control at what filled percentage the purge activities are run.
This replaces the default, hard coded 95% point.

The purge threshold defaults at the original 95%. I set a minimum
of 20 and max of 99 because those values felt sensible but am open
to changing those based on feedback.

Note: The purge threshold is still active when the keep option is
set. I added a note for this but this still presents some risk
where users who change this while in Keep mode could have their
services shut down earlier than they expect.

Patch: Fix a couple of typos in initial changes and improve
formatting.
This commit is contained in:
Christopher Leinbach
2024-12-13 10:44:20 -05:00
committed by Nachtzuster
parent bdc5802816
commit 23f52ae673
2 changed files with 4 additions and 6 deletions
+3 -5
View File
@@ -132,8 +132,8 @@ if(isset($_GET['submit'])) {
if (isset($_GET["purge_threshold"])) { if (isset($_GET["purge_threshold"])) {
$purge_threshold = $_GET["purge_threshold"]; $purge_threshold = $_GET["purge_threshold"];
if (strcmp($purge_threshold, $config['PURGE_THERSHOLD']) !== 0) { if (strcmp($purge_threshold, $config['PURGE_THRESHOLD']) !== 0) {
$contents = preg_replace("/PURGE_THERSHOLD=.*/", "PURGE_THERSHOLD=$purge_threshold", $contents); $contents = preg_replace("/PURGE_THRESHOLD=.*/", "PURGE_THRESHOLD=$purge_threshold", $contents);
} }
} }
@@ -306,9 +306,7 @@ $newconfig = get_config();
<br> <br>
<label for="purge_threshold">Purge Threshold (Disk Used %):</label> <label for="purge_threshold">Purge Threshold (Disk Used %):</label>
<input name="purge_threshold" type="number" style="width:6em;" min="20" max="99" step="1" value="<?php print($newconfig['PURGE_THRESHOLD']);?>"/> <input name="purge_threshold" type="number" style="width:6em;" min="20" max="99" step="1" value="<?php print($newconfig['PURGE_THRESHOLD']);?>"/>
</td></tr><tr><td> <p>Defines how full the disk should be before the purge operations occur.<br>Note: This variable is still active if Keep is set. This means that the servies will be stopped at the purge threshold.</p><br>
<p>Defines how full the disk should be before the purge operations occur.<br>Note: This variable is still active if Keep is set. This means that the servies will be stopped at the purge threshold.</p>
</td></tr><tr><td>
<label for="max_files_species">Amount of files to keep for each species :</label> <label for="max_files_species">Amount of files to keep for each species :</label>
<input name="max_files_species" type="number" style="width:6em;" min="0" step="1" value="<?php print($newconfig['MAX_FILES_SPECIES']);?>"/> <input name="max_files_species" type="number" style="width:6em;" min="0" step="1" value="<?php print($newconfig['MAX_FILES_SPECIES']);?>"/>
</td></tr><tr><td> </td></tr><tr><td>
+1 -1
View File
@@ -101,7 +101,7 @@ if ! grep -E '^COLOR_SCHEME=' /etc/birdnet/birdnet.conf &>/dev/null;then
fi fi
if ! grep -E '^PURGE_THRESHOLD=' /etc/birdnet/birdnet.conf &>/dev/null;then if ! grep -E '^PURGE_THRESHOLD=' /etc/birdnet/birdnet.conf &>/dev/null;then
echo "PURGE_THRESHOLD=\"95\"" >> /etc/birdnet/birdnet.conf echo "PURGE_THRESHOLD=95" >> /etc/birdnet/birdnet.conf
fi fi
if ! grep -E '^MAX_FILES_SPECIES=' /etc/birdnet/birdnet.conf &>/dev/null;then if ! grep -E '^MAX_FILES_SPECIES=' /etc/birdnet/birdnet.conf &>/dev/null;then