avoid using Utility.Touch without WITH_CLIBS

This commit is contained in:
Joey Hess 2013-11-12 21:05:04 -04:00
parent 4ae4ae78d7
commit 3e9419b088
2 changed files with 10 additions and 0 deletions

View file

@ -23,9 +23,11 @@ import Annex.Perms
import Annex.Link import Annex.Link
import qualified Annex import qualified Annex
import qualified Annex.Queue import qualified Annex.Queue
#ifdef WITH_CLIBS
#ifndef __ANDROID__ #ifndef __ANDROID__
import Utility.Touch import Utility.Touch
#endif #endif
#endif
import Config import Config
import Utility.InodeCache import Utility.InodeCache
import Annex.FileMatcher import Annex.FileMatcher
@ -211,12 +213,14 @@ link file key mcache = flip catchAnnex (undo file key) $ do
l <- inRepo $ gitAnnexLink file key l <- inRepo $ gitAnnexLink file key
replaceFile file $ makeAnnexLink l replaceFile file $ makeAnnexLink l
#ifdef WITH_CLIBS
#ifndef __ANDROID__ #ifndef __ANDROID__
-- touch symlink to have same time as the original file, -- touch symlink to have same time as the original file,
-- as provided in the InodeCache -- as provided in the InodeCache
case mcache of case mcache of
Just c -> liftIO $ touch file (TimeSpec $ inodeCacheToMtime c) False Just c -> liftIO $ touch file (TimeSpec $ inodeCacheToMtime c) False
Nothing -> noop Nothing -> noop
#endif
#endif #endif
return l return l

View file

@ -14,9 +14,11 @@ import System.PosixCompat.Files
import Common.Annex import Common.Annex
import Command import Command
import qualified Annex.Queue import qualified Annex.Queue
#ifdef WITH_CLIBS
#ifndef __ANDROID__ #ifndef __ANDROID__
import Utility.Touch import Utility.Touch
#endif #endif
#endif
def :: [Command] def :: [Command]
def = [notDirect $ noCommit $ command "fix" paramPaths seek def = [notDirect $ noCommit $ command "fix" paramPaths seek
@ -36,16 +38,20 @@ start file (key, _) = do
perform :: FilePath -> FilePath -> CommandPerform perform :: FilePath -> FilePath -> CommandPerform
perform file link = do perform file link = do
liftIO $ do liftIO $ do
#ifdef WITH_CLIBS
#ifndef __ANDROID__ #ifndef __ANDROID__
-- preserve mtime of symlink -- preserve mtime of symlink
mtime <- catchMaybeIO $ TimeSpec . modificationTime mtime <- catchMaybeIO $ TimeSpec . modificationTime
<$> getSymbolicLinkStatus file <$> getSymbolicLinkStatus file
#endif
#endif #endif
createDirectoryIfMissing True (parentDir file) createDirectoryIfMissing True (parentDir file)
removeFile file removeFile file
createSymbolicLink link file createSymbolicLink link file
#ifdef WITH_CLIBS
#ifndef __ANDROID__ #ifndef __ANDROID__
maybe noop (\t -> touch file t False) mtime maybe noop (\t -> touch file t False) mtime
#endif
#endif #endif
next $ cleanup file next $ cleanup file