From 421941d3e9d304befcbfa614ce35d34afb64c5f0 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 7 Feb 2026 20:33:07 +0100 Subject: First implementation of ftag sync push It looks like both ftag sync push and pull are working. --- src/main.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 5340cb0..13f5eba 100644 --- a/src/main.c +++ b/src/main.c @@ -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 -- cgit v1.2.3