From bf460a0a98d7e4c7f4eac525fcf300629db582b6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Nov 2011 15:34:10 -0400 Subject: reorder repo parameters last Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators. --- Remote/Rsync.hs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Remote/Rsync.hs') diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index e79762a38..0dfad7293 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -90,15 +90,12 @@ rsyncKeyDir :: RsyncOpts -> Key -> String rsyncKeyDir o k = rsyncUrl o hashDirMixed k shellEscape (keyFile k) store :: RsyncOpts -> Key -> Annex Bool -store o k = do - g <- gitRepo - rsyncSend o k (gitAnnexLocation g k) +store o k = rsyncSend o k =<< fromRepo (gitAnnexLocation k) storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> Annex Bool storeEncrypted o (cipher, enck) k = withTmp enck $ \tmp -> do - g <- gitRepo - let f = gitAnnexLocation g k - liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s + src <- fromRepo $ gitAnnexLocation k + liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp rsyncSend o enck tmp retrieve :: RsyncOpts -> Key -> FilePath -> Annex Bool @@ -151,9 +148,9 @@ partialParams = Params "--no-inplace --partial --partial-dir=.rsync-partial" - up trees for rsync. -} withRsyncScratchDir :: (FilePath -> Annex Bool) -> Annex Bool withRsyncScratchDir a = do - g <- gitRepo pid <- liftIO getProcessID - let tmp = gitAnnexTmpDir g "rsynctmp" show pid + t <- fromRepo gitAnnexTmpDir + let tmp = t "rsynctmp" show pid nuke tmp liftIO $ createDirectoryIfMissing True tmp res <- a tmp -- cgit v1.2.3