chiark / gitweb /
path_check_timestamp: only keep the most recent timestamp
[elogind.git] / src / shared / path-util.c
index def7a7409a30ed85ef8ebf573b5df489977f81b8..fcacf541ed83970be11fc44b842ae380bcb1ed88 100644 (file)
@@ -474,11 +474,13 @@ int find_binary(const char *name, char **filename) {
         }
 }
 
-bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update)
+bool paths_check_timestamp(char **paths, usec_t *timestamp, bool update)
 {
         unsigned int i;
         bool changed = false;
 
+        assert(timestamp);
+
         if (paths == NULL)
                 goto out;
 
@@ -488,18 +490,16 @@ bool paths_check_timestamp(char **paths, usec_t *paths_ts_usec, bool update)
                 if (stat(paths[i], &stats) < 0)
                         continue;
 
-                if (paths_ts_usec[i] == timespec_load(&stats.st_mtim))
+                /* first check */
+                if (*timestamp >= timespec_load(&stats.st_mtim))
                         continue;
 
-                /* first check */
-                if (paths_ts_usec[i] != 0) {
-                        log_debug("reload - timestamp of '%s' changed\n", paths[i]);
-                        changed = true;
-                }
+                log_debug("timestamp of '%s' changed\n", paths[i]);
+                changed = true;
 
                 /* update timestamp */
                 if (update)
-                        paths_ts_usec[i] = timespec_load(&stats.st_mtim);
+                        *timestamp = timespec_load(&stats.st_mtim);
         }
 out:
         return changed;