on master help sign in
Preserve file metadata in copyFileCompiler
commitba272c9ba9cddb306cd30c976fb95a8ae7a06b85 authorfrederik-h <frederik-h@users.noreply.github.com> dateSat 11 Feb 2017, 18:18 (10 years ago) parentfbd2c6d
1 file changed+11−3
src/Hakyll/Core/File.hs+11−3
src/Hakyll/Core/File.hs+11−3
@@ -1,5 +1,6 @@
11--------------------------------------------------------------------------------
22-- | Exports simple compilers to just copy files
3+{-# LANGUAGE CPP #-}
34{-# LANGUAGE DeriveDataTypeable #-}
45{-# LANGUAGE GeneralizedNewtypeDeriving #-}
56module Hakyll.Core.File
@@ -13,7 +14,12 @@ module Hakyll.Core.File
1314--------------------------------------------------------------------------------
1415import Data.Binary (Binary (..))
1516import Data.Typeable (Typeable)
16−import System.Directory (copyFile, doesFileExist,
17+#if MIN_VERSION_directory(1,2,6)
18+import System.Directory (copyFileWithMetadata)
19+#else
20+import System.Directory (copyFile)
21+#endif
22+import System.Directory (doesFileExist,
1723 renameFile)
1824import System.FilePath ((</>))
1925import System.Random (randomIO)
@@ -38,9 +44,11 @@ newtype CopyFile = CopyFile FilePath
3844
3945--------------------------------------------------------------------------------
4046instance Writable CopyFile where
47+#if MIN_VERSION_directory(1,2,6)
48+ write dst (Item _ (CopyFile src)) = copyFileWithMetadata src dst
49+#else
4150 write dst (Item _ (CopyFile src)) = copyFile src dst
42−
43−
51+#endif
4452--------------------------------------------------------------------------------
4553copyFileCompiler :: Compiler (Item CopyFile)
4654copyFileCompiler = do