From ba272c9ba9cddb306cd30c976fb95a8ae7a06b85 Mon Sep 17 00:00:00 2001 From: frederik-h Date: Sat, 11 Feb 2017 18:18:23 +0100 Subject: Preserve file metadata in copyFileCompiler --- src/Hakyll/Core/File.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Hakyll') diff --git a/src/Hakyll/Core/File.hs b/src/Hakyll/Core/File.hs index 1c3a9df..49af659 100644 --- a/src/Hakyll/Core/File.hs +++ b/src/Hakyll/Core/File.hs @@ -1,5 +1,6 @@ -------------------------------------------------------------------------------- -- | Exports simple compilers to just copy files +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Hakyll.Core.File @@ -13,7 +14,12 @@ module Hakyll.Core.File -------------------------------------------------------------------------------- import Data.Binary (Binary (..)) import Data.Typeable (Typeable) -import System.Directory (copyFile, doesFileExist, +#if MIN_VERSION_directory(1,2,6) +import System.Directory (copyFileWithMetadata) +#else +import System.Directory (copyFile) +#endif +import System.Directory (doesFileExist, renameFile) import System.FilePath (()) import System.Random (randomIO) @@ -38,9 +44,11 @@ newtype CopyFile = CopyFile FilePath -------------------------------------------------------------------------------- instance Writable CopyFile where +#if MIN_VERSION_directory(1,2,6) + write dst (Item _ (CopyFile src)) = copyFileWithMetadata src dst +#else write dst (Item _ (CopyFile src)) = copyFile src dst - - +#endif -------------------------------------------------------------------------------- copyFileCompiler :: Compiler (Item CopyFile) copyFileCompiler = do -- cgit v1.2.3