diff options
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r-- | Command/Fsck.hs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 1c9af0d34..fe1d35162 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -5,8 +5,12 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Command.Fsck where +import System.PosixCompat.Files + import Common.Annex import Command import qualified Annex @@ -28,7 +32,11 @@ import qualified Option import Types.Key import Utility.HumanTime +#ifndef __WINDOWS__ import System.Posix.Process (getProcessID) +#else +import System.Random (getStdRandom, random) +#endif import Data.Time.Clock.POSIX import Data.Time import System.Posix.Types (EpochTime) @@ -138,10 +146,14 @@ performRemote key file backend numcopies remote = , checkKeyNumCopies key file numcopies ] withtmp a = do - pid <- liftIO getProcessID +#ifndef __WINDOWS__ + v <- liftIO getProcessID +#else + v <- liftIO (getStdRandom random :: IO Int) +#endif t <- fromRepo gitAnnexTmpDir createAnnexDirectory t - let tmp = t </> "fsck" ++ show pid ++ "." ++ keyFile key + let tmp = t </> "fsck" ++ show v ++ "." ++ keyFile key let cleanup = liftIO $ catchIO (removeFile tmp) (const noop) cleanup cleanup `after` a tmp @@ -449,7 +461,9 @@ recordFsckTime key = do parent <- parentDir <$> calcRepo (gitAnnexLocation key) liftIO $ void $ tryIO $ do touchFile parent +#ifndef __WINDOWS__ setSticky parent +#endif getFsckTime :: Key -> Annex (Maybe EpochTime) getFsckTime key = do |