summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2017-12-18 21:26:29 +0900
committerAkira TAGOH <akira@tagoh.org>2017-12-18 21:26:29 +0900
commit182186e53a38d2c8b82d0a1785f6873f2b54316a (patch)
tree0baa2f47faa1bf669fe89d7627eb76982e91bfe7 /src
parentc1e48b0c1439007b41887177ef7b34e4d75e3a31 (diff)
Do not update mtime with creating .uuid
Diffstat (limited to 'src')
-rw-r--r--src/fccache.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/fccache.c b/src/fccache.c
index dfe9520f..33c8a11f 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -30,6 +30,7 @@
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <assert.h>
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
# include <unistd.h>
@@ -63,7 +64,14 @@ FcDirCacheCreateUUID (FcChar8 *dir,
uuid_t uuid;
char out[37];
FcBool (* hash_add) (FcHashTable *, void*, void*);
+ struct stat statb;
+ struct timeval times[2];
+ if (FcStat (dir, &statb) != 0)
+ {
+ ret = FcFalse;
+ goto bail1;
+ }
atomic = FcAtomicCreate (uuidname);
if (!atomic)
{
@@ -101,6 +109,24 @@ FcDirCacheCreateUUID (FcChar8 *dir,
FcAtomicUnlock (atomic);
bail2:
FcAtomicDestroy (atomic);
+
+ if (ret)
+ {
+ /* revert mtime of the directory */
+ times[0].tv_sec = statb.st_atime;
+ times[1].tv_sec = statb.st_mtime;
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ times[0].tv_usec = statb.st_atim.tv_nsec / 1000;
+ times[1].tv_usec = statb.st_mtim.tv_nsec / 1000;
+#else
+ times[0].tv_usec = 0;
+ times[1].tv_usec = 0;
+#endif
+ if (utimes ((const char *) dir, times) != 0)
+ {
+ fprintf (stderr, "Unable to revert mtime: %s\n", dir);
+ }
+ }
}
bail1:
FcStrFree (uuidname);