Merge (#10) from tomasriveral/multiple-vault-directories

things i forgot to fix or that i broke last time.
This commit is contained in:
2026-04-26 22:10:08 +02:00
committed by GitHub
2 changed files with 8 additions and 3 deletions
+5 -2
View File
@@ -171,7 +171,10 @@ Edit `~/.config/notewrapper/config.json`. If it does not exist, it will be creat
"newLineOnOpening": true, "newLineOnOpening": true,
"backup": { "backup": {
"enable": false, "enable": false,
"directory": "/path/to/backup", "directory": {
"~/Documents/Notes": "path/to/backup1",
"/other/paths/": "path/to/backup2"
},
"interval": "weekly", "interval": "weekly",
"rsyncArgs": ["-Lqah", "--update"] "rsyncArgs": ["-Lqah", "--update"]
} }
@@ -188,7 +191,7 @@ Edit `~/.config/notewrapper/config.json`. If it does not exist, it will be creat
* `dateEntry`: format for journal entries (see `strftime`) * `dateEntry`: format for journal entries (see `strftime`)
* `newLineOnOpening`: add a newline when opening a note * `newLineOnOpening`: add a newline when opening a note
* `backup.enable`: enable automatic backups using `rsync` * `backup.enable`: enable automatic backups using `rsync`
* `backup.directory`: destination directory for backups * `backup.directory`: backup's destination for each directory
* `backup.interval`: backup frequency (`daily`, `weekly`, `monthly`, or integer) * `backup.interval`: backup frequency (`daily`, `weekly`, `monthly`, or integer)
* `backup.rsyncArgs`: arguments passed to `rsync` * `backup.rsyncArgs`: arguments passed to `rsync`
+3 -1
View File
@@ -2,6 +2,7 @@
#include "ui.h" #include "ui.h"
#include "utils.h" #include "utils.h"
#include "notes.h" #include "notes.h"
#include <errno.h>
#include <stdio.h> #include <stdio.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@@ -209,7 +210,8 @@ arg_next:
// handles the path to the backup for each directory // handles the path to the backup for each directory
cJSON *pathToBackupJSON = cJSON_GetObjectItem(backupJSON, "directory"); cJSON *pathToBackupJSON = cJSON_GetObjectItem(backupJSON, "directory");
error(cJSON_IsObject(pathToBackupJSON), "user", "In %s, incorrect type for \"backup\". It must be a JSON object."); debug("%s", cJSON_Print(pathToBackupJSON));
error(pathToBackupJSON == NULL && !(cJSON_IsObject(pathToBackupJSON) || cJSON_IsArray(pathToBackupJSON) || cJSON_IsString(pathToBackupJSON) || cJSON_IsNumber(pathToBackupJSON) || cJSON_IsBool(pathToBackupJSON)), "user", "In %s, incorrect type for \"directory\". It must be a JSON object.", configPath); // for some reason cJSON_IsObject does not work. So we must do it like this.
for (int i = 0; i < numDirectories; i++) { // we iterate over every for (int i = 0; i < numDirectories; i++) { // we iterate over every
cJSON *pathToBackupForIthDirectoryJSON = cJSON_GetObjectItem(pathToBackupJSON, directoriesArray[i]); cJSON *pathToBackupForIthDirectoryJSON = cJSON_GetObjectItem(pathToBackupJSON, directoriesArray[i]);
if (pathToBackupForIthDirectoryJSON) { if (pathToBackupForIthDirectoryJSON) {