Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ Edit `~/.config/notewrapper/config.json`. If it does not exist, it will be creat
"newLineOnOpening": true,
"backup": {
"enable": false,
"directory": "/path/to/backup",
"directory": {
"~/Documents/Notes": "path/to/backup1",
"/other/paths/": "path/to/backup2"
},
"interval": "weekly",
"rsyncArgs": ["-Lqah", "--update"]
}
Expand All @@ -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`)
* `newLineOnOpening`: add a newline when opening a note
* `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.rsyncArgs`: arguments passed to `rsync`

Expand Down
4 changes: 3 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui.h"
#include "utils.h"
#include "notes.h"
#include <errno.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
Expand Down Expand Up @@ -209,7 +210,8 @@ int main(int argc, char *argv[]) {

// handles the path to the backup for each 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
cJSON *pathToBackupForIthDirectoryJSON = cJSON_GetObjectItem(pathToBackupJSON, directoriesArray[i]);
if (pathToBackupForIthDirectoryJSON) {
Expand Down