aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2026-02-07 16:53:08 +0100
committerTristan Riehs <tristan.riehs@inria.fr>2026-02-07 16:53:08 +0100
commit5bef2425f567c6488b4eed09de749ab4bbfdfd0c (patch)
tree36171e62d574c9ae7dc87e61459823a08285e81b
parent7e68ac94c7937d071b2459af483b16d9620d8d97 (diff)
First implementation of ftag sync pull
-rw-r--r--src/main.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index aa037fb..5340cb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,6 +11,7 @@
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
+#include <utime.h>
#ifndef FTAG_REMOTE_HOST
#define FTAG_REMOTE_HOST "localhost"
@@ -1116,7 +1117,7 @@ static time_t get_remote_mtime(void)
static time_t get_local_mtime(void)
{
struct stat st;
- rc = stat(DATABASE_PATH, &st);
+ int rc = stat(DATABASE_PATH, &st);
if (rc == -1) {
fprintf(stderr, "stat: %s: ", DATABASE_PATH);
perror("");
@@ -1149,9 +1150,17 @@ static void ftag_sync_pull(void)
NULL
};
ftag_execvp(cmd, 1);
- /* TODO: manually set local and remote mtime
-
- Make them equal to avoid further unecessary pull/push. */
+ time_t remote_mtime = get_remote_mtime();
+ struct utimbuf times = {
+ .actime = remote_mtime,
+ .modtime = remote_mtime
+ };
+ int rc = utime(DATABASE_PATH, &times);
+ if (rc == -1) {
+ fprintf(stderr, "utime: %s:", DATABASE_PATH);
+ perror("");
+ exit(EXIT_FAILURE);
+ }
}
static void ftag_sync(int argc, char **argv)