feat: allow the usage of multiple vault directories

This commit is contained in:
2026-04-26 20:45:42 +02:00
parent e2343dd401
commit 107519507f
7 changed files with 131 additions and 82 deletions
+7 -3
View File
@@ -136,7 +136,7 @@ void initAppFilesAndDirs(const char *home, const int shouldDebug) {
debug("Creating default config file.");
FILE *w = fopen(config_file, "w");
error(!w, "program", "fopen failed opening %s");
fprintf(w,
fprintf(w, //TODO CHANGE default json
"{\n"
" \"directory\": \"~/Documents/Notes/\",\n"
" \"render\": true,\n"
@@ -156,7 +156,7 @@ void initAppFilesAndDirs(const char *home, const int shouldDebug) {
fclose(w);
}
void handleBackups(const char *pathOfVaults, const char *pathOfBackup, const char *homeDir, const int interval, const char **rsyncArguments, const int rsyncArgumentsNumber, const int shouldDebug) {
void handleBackups(char **sourceDirectoryArray, const int sourceNumber, char **destinationDirectoryArray, const char *homeDir, const int interval, const char **rsyncArguments, const int rsyncArgumentsNumber, const int shouldDebug) {
int shouldBackup = 0;
time_t now = time(NULL);
debug("Time since epoch is %ld", (long)now);
@@ -202,7 +202,11 @@ void handleBackups(const char *pathOfVaults, const char *pathOfBackup, const cha
}
if (shouldBackup) {
copyDir(pathOfVaults, pathOfBackup, rsyncArguments, rsyncArgumentsNumber, shouldDebug);
for (int i = 0; i < sourceNumber; i++) {
if (destinationDirectoryArray[i]) { // if we don't want to backup it, it was set to NULL
copyDir(sourceDirectoryArray[i], destinationDirectoryArray[i], rsyncArguments, rsyncArgumentsNumber, shouldDebug);
}
}
}
}