Default to not delete logs

This commit is contained in:
amcmanu3 2023-03-02 13:40:45 -05:00
parent 6e35d4ae97
commit 39190ed43b
2 changed files with 16 additions and 13 deletions

View File

@ -441,7 +441,7 @@ class Helpers:
"reset_secrets_on_next_boot": False,
"monitored_mounts": mounts,
"dir_size_poll_freq_minutes": 5,
"crafty_logs_delete_after_days": 14,
"crafty_logs_delete_after_days": 0,
}
def get_all_settings(self):

View File

@ -774,16 +774,19 @@ class TasksManager:
"session.log",
"commander.log",
]
log_files = list(
filter(
lambda val: val not in latest_log_files,
os.listdir(logs_path),
# we won't delete if delete logs after is set to 0
if logs_delete_after != 0:
log_files = list(
filter(
lambda val: val not in latest_log_files,
os.listdir(logs_path),
)
)
)
for log_file in log_files:
log_file_path = os.path.join(logs_path, log_file)
if Helpers.check_file_exists(
log_file_path
) and Helpers.is_file_older_than_x_days(log_file_path, logs_delete_after):
os.remove(log_file_path)
for log_file in log_files:
log_file_path = os.path.join(logs_path, log_file)
if Helpers.check_file_exists(
log_file_path
) and Helpers.is_file_older_than_x_days(
log_file_path, logs_delete_after
):
os.remove(log_file_path)