diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-01-18 21:27:36 +0100 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-01-18 21:27:36 +0100 |
| commit | 9287fa4c42ac77b51fe1bdee485eff72659204e7 (patch) | |
| tree | 7848b120c85b989d2383e5c2a1c2ac0ce8c6bc18 | |
| parent | 07d0f65cac8483911da2ac692c106d6061509e9d (diff) | |
Start implementing the sync command
| -rw-r--r-- | src/main.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -12,6 +12,15 @@ #include <time.h> #include <unistd.h> +#ifndef FTAG_REMOTE_HOST +#define FTAG_REMOTE_HOST "localhost" +#endif + +#ifndef FTAG_REMOTE_ROOT +/* HOME on remote host */ +#define FTAG_REMOTE_ROOT (FTAG_ROOT "/ftag.sqlite3.bak") +#endif + #define DATABASE_PATH (FTAG_ROOT "/ftag.sqlite3") /* Used when encrypting or decrpyting a file, see the copy_encrypted_file @@ -1064,6 +1073,17 @@ static void ftag_query(int argc, char **argv) free(tags); } +static void ftag_sync(int argc, char **argv) +{ + struct stat st; + char *remote_path = FTAG_REMOTE_ROOT "/ftag.sqlite3"; + char cmd[1024]; + strbuild(cmd, "ssh %s sh -c 'test -f %s && stat --format=%%Y %s || echo 0'", + FTAG_REMOTE_HOST, remote_path, remote_path); + FILE *stream = popen(cmd, "r"); + int rc = stat(DATABASE_PATH, &st); +} + /* Check that the tag we are trying to create does not exist yet. If this * callback is ever called, then it already exist, this is a fatal error. */ static int ftag_tag_check(void *, int, char **cols, char **) @@ -1175,6 +1195,7 @@ int main(int argc, char *argv[]) {.name = "--help", .func = ftag_help}, {.name = "help", .func = ftag_help}, {.name = "query", .func = ftag_query}, + {.name = "sync", .func = ftag_sync}, {.name = "tag", .func = ftag_tag} /* TODO: add a "sync" command |
