on master help sign in
save modification time with sub-second granularity

Some systems can get the file modification time with sub-second granularity. However, Hakyll shaves off the sub-seconds, as defined in the Binary instance of BinaryTime, which poses a problem because when a file is checked to see if it was modified in `resourceModified`, it still contains the sub-seconds. This results in a file (almost) always being considered as having been modified. Example: 1. First go around, modification time is 3:45.325. This time is saved as 3:45.000 (i.e. sub-seconds are shaved off). 2. Second go around, modification time is again read as 3:45.325 and compared against the stored time, 3:45.000. 3:45.325 is more recent than 3:45.000, so the file is considered to have been modified. This change prevents the shaving off of sub-seconds. This will naturally work on systems that don't support sub-second granularity, as that 'field' will simply appear as all zeros. Closes #250

commitd86b4753d4811a0f1bd1004e83296238c83a383a authorJorge Israel Peña <jorge.israel.p@gmail.com> dateFri 9 May 2014, 02:11 (12 years ago) parent43c2aea
1 file changed+3−4
src/Hakyll/Core/Provider/Internal.hs+3−4
src/Hakyll/Core/Provider/Internal.hs+3−4
@@ -31,8 +31,7 @@ import Data.Maybe (fromMaybe)
3131import Data.Monoid (mempty)
3232import Data.Set (Set)
3333import qualified Data.Set as S
34−import Data.Time (Day (..), UTCTime (..),
35− secondsToDiffTime)
34+import Data.Time (Day (..), UTCTime (..))
3635import Data.Typeable (Typeable)
3736import System.Directory (getModificationTime)
3837import System.FilePath (addExtension, (</>))
@@ -62,11 +61,11 @@ newtype BinaryTime = BinaryTime {unBinaryTime :: UTCTime}
6261--------------------------------------------------------------------------------
6362instance Binary BinaryTime where
6463 put (BinaryTime (UTCTime (ModifiedJulianDay d) dt)) =
65− put d >> put (floor dt :: Integer)
64+ put d >> put (toRational dt)
6665
6766 get = fmap BinaryTime $ UTCTime
6867 <$> (ModifiedJulianDay <$> get)
69− <*> (secondsToDiffTime <$> get)
68+ <*> (fromRational <$> get)
7069
7170
7271--------------------------------------------------------------------------------