Merge (#23) from tomasriveral/backupDebug fix (#22)

fix (#22): backup
This commit is contained in:
2026-05-02 07:58:03 +02:00
committed by GitHub
+4 -4
View File
@@ -202,9 +202,9 @@ void handleBackups(char **sourceDirectoryArray, const int sourceNumber, char **d
if (endptr == line || (*endptr != '\n' && *endptr != '\0')) { if (endptr == line || (*endptr != '\n' && *endptr != '\0')) {
error(1, "program", "Invalid timestamp in cache file: %s", line); error(1, "program", "Invalid timestamp in cache file: %s", line);
} }
double deltaTime = difftime(now, lastBackupTime);
if (difftime(now, lastBackupTime) > interval) { if (deltaTime > interval) {
debug("(difftime) %d is greater than (interval) %d -> backuping...", difftime(now, lastBackupTime), interval); debug("(difftime) %f is greater than (interval) %d -> backuping...", deltaTime, interval);
shouldBackup = 1; shouldBackup = 1;
cacheFile = fopen(cacheFilePATH, "w"); cacheFile = fopen(cacheFilePATH, "w");
if (!cacheFile) { if (!cacheFile) {
@@ -213,7 +213,7 @@ void handleBackups(char **sourceDirectoryArray, const int sourceNumber, char **d
fprintf(cacheFile, "%ld\n", (long)now); fprintf(cacheFile, "%ld\n", (long)now);
fclose(cacheFile); fclose(cacheFile);
} else { } else {
debug("(difftime) %d is smaller than (interval) %d -> no need to backup.", difftime(now, lastBackupTime), interval); debug("(difftime) %f is smaller than (interval) %d -> no need to backup.", deltaTime, interval);
} }
} }