fontconfig: Branch 'master'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 src/fccache.c    |   26 ++++++++++++++++++++++++++
 test/run-test.sh |   13 +++++++++++++
 2 files changed, 39 insertions(+)

New commits:
commit 182186e53a38d2c8b82d0a1785f6873f2b54316a
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Dec 18 21:26:29 2017 +0900

    Do not update mtime with creating .uuid

diff --git a/src/fccache.c b/src/fccache.c
index dfe9520..33c8a11 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);
diff --git a/test/run-test.sh b/test/run-test.sh
index 4154dd3..436dee1 100644
--- a/test/run-test.sh
+++ b/test/run-test.sh
@@ -164,6 +164,19 @@ if [ $n != 1 ]; then
   exit 1
 fi
 
+dotest "Keep mtime of the font directory"
+prep
+cp $FONT1 $FONTDIR
+touch -d @0 $FONTDIR
+stat $FONTDIR | grep Modify > out1
+$FCCACHE $FONTDIR
+stat $FONTDIR | grep Modify > out2
+if cmp out1 out2 > /dev/null ; then : ; else
+    echo "*** Test failed: $TEST"
+    echo "mtime was modified"
+    exit 1
+fi
+
 if [ x"$BWRAP" != "x" ]; then
 dotest "Basic functionality with the bind-mounted cache dir"
 prep
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux