mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Do not compress rotated files - they are not expected to be large
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+1
-1
@@ -1344,7 +1344,7 @@ void readFTLconf(struct config *conf, const bool rewrite)
|
||||
// If we cannot parse /etc/pihole.toml (due to missing or invalid syntax),
|
||||
// we try to read the rotated files in /etc/pihole/config_backup starting at
|
||||
// the most recent one and going back in time until we find a valid config
|
||||
for(unsigned int i = 0; i < PLAIN_ROTATIONS; i++)
|
||||
for(unsigned int i = 0; i < MAX_ROTATIONS; i++)
|
||||
{
|
||||
if(readFTLtoml(NULL, conf, NULL, rewrite, NULL, i))
|
||||
{
|
||||
|
||||
-45
@@ -26,8 +26,6 @@
|
||||
#include <sys/statvfs.h>
|
||||
// dirname()
|
||||
#include <libgen.h>
|
||||
// compression functions
|
||||
#include "zip/gzip.h"
|
||||
// sendfile()
|
||||
#include <fcntl.h>
|
||||
#include <sys/sendfile.h>
|
||||
@@ -463,14 +461,6 @@ void rotate_files(const char *path, char **first_file)
|
||||
if(i == 1 && first_file != NULL)
|
||||
*first_file = strdup(new_path);
|
||||
|
||||
size_t old_path_len = strlen(old_path) + 4;
|
||||
char *old_path_compressed = calloc(old_path_len, sizeof(char));
|
||||
snprintf(old_path_compressed, old_path_len, "%s.gz", old_path);
|
||||
|
||||
size_t new_path_len = strlen(new_path) + 4;
|
||||
char *new_path_compressed = calloc(new_path_len, sizeof(char));
|
||||
snprintf(new_path_compressed, new_path_len, "%s.gz", new_path);
|
||||
|
||||
if(file_exists(old_path))
|
||||
{
|
||||
// Copy file to backup directory
|
||||
@@ -505,46 +495,11 @@ void rotate_files(const char *path, char **first_file)
|
||||
|
||||
// Change ownership of file to pihole user
|
||||
chown_pihole(new_path);
|
||||
|
||||
// Compress file if we are rotating a sufficiently old file
|
||||
if(i > PLAIN_ROTATIONS)
|
||||
{
|
||||
log_debug(DEBUG_CONFIG, "Compressing %s -> %s",
|
||||
new_path, new_path_compressed);
|
||||
if(deflate_file(new_path, new_path_compressed, false))
|
||||
{
|
||||
// On success, we remove the uncompressed file
|
||||
remove(new_path);
|
||||
}
|
||||
|
||||
// Change ownership of file to pihole user
|
||||
chown_pihole(new_path_compressed);
|
||||
}
|
||||
}
|
||||
else if(file_exists(old_path_compressed))
|
||||
{
|
||||
// Rename file
|
||||
if(rename(old_path_compressed, new_path_compressed) < 0)
|
||||
{
|
||||
log_warn("Rotation %s -(MOVE)> %s failed: %s",
|
||||
old_path_compressed, new_path_compressed, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log success if debug is enabled
|
||||
log_debug(DEBUG_CONFIG, "Rotated %s -> %s",
|
||||
old_path_compressed, new_path_compressed);
|
||||
}
|
||||
|
||||
// Change ownership of file to pihole user
|
||||
chown_pihole(new_path_compressed);
|
||||
}
|
||||
|
||||
// Free memory
|
||||
free(old_path);
|
||||
free(new_path);
|
||||
free(old_path_compressed);
|
||||
free(new_path_compressed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
// setmntent()
|
||||
#include <mntent.h>
|
||||
|
||||
#define PLAIN_ROTATIONS 3
|
||||
#define MAX_ROTATIONS 15
|
||||
#define BACKUP_DIR "/etc/pihole/config_backups"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user