diff options
author | Joey Hess <joey@kitenet.net> | 2013-07-11 11:39:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-07-11 11:39:42 -0400 |
commit | 8ef46b1838eea40488617df6d344d50fd5877ea5 (patch) | |
tree | 9070dab27245bea49fc74e4cd014dd0ff4835e3a /Command/Fix.hs | |
parent | c2e979dbac504d0c20cdf99c336b479c79fb6c7b (diff) |
fix: Preserve the original mtime of fixed symlinks.
Diffstat (limited to 'Command/Fix.hs')
-rw-r--r-- | Command/Fix.hs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Command/Fix.hs b/Command/Fix.hs index c6b4df257..da2627619 100644 --- a/Command/Fix.hs +++ b/Command/Fix.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Command.Fix where import System.PosixCompat.Files @@ -12,6 +14,9 @@ import System.PosixCompat.Files import Common.Annex import Command import qualified Annex.Queue +#ifndef __ANDROID__ +import Utility.Touch +#endif def :: [Command] def = [notDirect $ noCommit $ command "fix" paramPaths seek @@ -30,9 +35,18 @@ start file (key, _) = do perform :: FilePath -> FilePath -> CommandPerform perform file link = do - liftIO $ createDirectoryIfMissing True (parentDir file) - liftIO $ removeFile file - liftIO $ createSymbolicLink link file + liftIO $ do +#ifndef __ANDROID__ + -- preserve mtime of symlink + mtime <- catchMaybeIO $ TimeSpec . modificationTime + <$> getSymbolicLinkStatus file +#endif + createDirectoryIfMissing True (parentDir file) + removeFile file + createSymbolicLink link file +#ifndef __ANDROID__ + maybe noop (\t -> touch file t False) mtime +#endif next $ cleanup file cleanup :: FilePath -> CommandCleanup |