From 5e57047d874e0f01dcb3bbc8b809fcc1aa82755b Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Wed, 15 Feb 2012 01:00:30 +0100
Subject: [PATCH] Fix a broken guard around utime()

Because of an outdated check for a timestamp of 0, we were calling
utime() even when it wasn't necessary.
---
 src/libstore/local-store.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 771776f6a..a30839643 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -394,6 +394,9 @@ void LocalStore::openDB(bool create)
 }
 
 
+const time_t mtimeStore = 1; /* 1 second into the epoch */
+
+
 void canonicalisePathMetaData(const Path & path, bool recurse)
 {
     checkInterrupt();
@@ -433,10 +436,10 @@ void canonicalisePathMetaData(const Path & path, bool recurse)
                 throw SysError(format("changing mode of `%1%' to %2$o") % path % mode);
         }
 
-        if (st.st_mtime != 0) {
+        if (st.st_mtime != mtimeStore) {
             struct utimbuf utimbuf;
             utimbuf.actime = st.st_atime;
-            utimbuf.modtime = 1; /* 1 second into the epoch */
+            utimbuf.modtime = mtimeStore;
             if (utime(path.c_str(), &utimbuf) == -1) 
                 throw SysError(format("changing modification time of `%1%'") % path);
         }
-- 
GitLab