diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-02-07 20:33:07 +0100 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-02-07 20:36:33 +0100 |
| commit | 421941d3e9d304befcbfa614ce35d34afb64c5f0 (patch) | |
| tree | ac3547b956dbcdae18e63b411690995b2e4b31d8 | |
| parent | 5bef2425f567c6488b4eed09de749ab4bbfdfd0c (diff) | |
First implementation of ftag sync push
It looks like both ftag sync push and pull are working.
| -rw-r--r-- | src/main.c | 43 |
1 files changed, 41 insertions, 2 deletions
@@ -1163,10 +1163,49 @@ static void ftag_sync_pull(void) } } +static void ftag_sync_push(void) +{ + if (!ftag_sync_is_local_newer()) + return; + char remote_arg[128]; + strbuild(remote_arg, "%s:%s/%s", + FTAG_REMOTE_HOST, FTAG_REMOTE_ROOT, "ftag.sqlite3"); + char *cmd_scp[] = { + "scp", + DATABASE_PATH, + remote_arg, + NULL + }; + ftag_execvp(cmd_scp, 1); + time_t local_mtime = get_local_mtime(); + char mtime_date[64]; + strbuild(mtime_date, "@%ld", local_mtime); + char remote_path[128]; + strbuild(remote_path, "%s/ftag.sqlite3", FTAG_REMOTE_ROOT); + char *cmd_ssh_touch[] = { + "ssh", + FTAG_REMOTE_HOST, + "touch", + "--date", + mtime_date, + remote_path, + NULL + }; + ftag_execvp(cmd_ssh_touch, 1); +} + static void ftag_sync(int argc, char **argv) { - (void) argc; - (void) argv; + /* TODO: make this a real command + + Add a help command. */ + assert(argc >= 1); + if (strcmp(argv[0], "pull") == 0) { + ftag_sync_pull(); + } + else if (strcmp(argv[0], "push") == 0) { + ftag_sync_push(); + } } /* Check that the tag we are trying to create does not exist yet. If this |
