diff options
author | 2012-08-27 14:49:09 -0400 | |
---|---|---|
committer | 2012-08-27 14:49:09 -0400 | |
commit | c1adde5294fe995c2d92f1ac81a2295bbbef62d4 (patch) | |
tree | a50eb6a55220fbdc28abf1af7936d64590364756 /Remote/Bup.hs | |
parent | 8660f3043c8968dc231727fe151063197f491a5f (diff) | |
parent | 1cbfd6368c5b82f7559fb1f1da1209ba0c37a793 (diff) |
finally merge the assistant into master
Progress bars still need to be done, otherwise it's fully working.
Although much work remains to hit all the use cases.
Diffstat (limited to 'Remote/Bup.hs')
-rw-r--r-- | Remote/Bup.hs | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs index 0d1b606d3..e3ba7fe9b 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -13,6 +13,7 @@ import System.Process import Common.Annex import Types.Remote +import Types.Key import qualified Git import qualified Git.Command import qualified Git.Config @@ -46,21 +47,25 @@ gen r u c = do return $ encryptableRemote c (storeEncrypted r buprepo) (retrieveEncrypted buprepo) - Remote { - uuid = u', - cost = cst, - name = Git.repoDescribe r, - storeKey = store r buprepo, - retrieveKeyFile = retrieve buprepo, - retrieveKeyFileCheap = retrieveCheap buprepo, - removeKey = remove, - hasKey = checkPresent r bupr', - hasKeyCheap = bupLocal buprepo, - whereisKey = Nothing, - config = c, - repo = r, - remotetype = remote - } + Remote + { uuid = u' + , cost = cst + , name = Git.repoDescribe r + , storeKey = store r buprepo + , retrieveKeyFile = retrieve buprepo + , retrieveKeyFileCheap = retrieveCheap buprepo + , removeKey = remove + , hasKey = checkPresent r bupr' + , hasKeyCheap = bupLocal buprepo + , whereisKey = Nothing + , config = c + , repo = r + , localpath = if bupLocal buprepo && not (null buprepo) + then Just buprepo + else Nothing + , remotetype = remote + , readonly = False + } bupSetup :: UUID -> RemoteConfig -> Annex RemoteConfig bupSetup u c = do @@ -133,13 +138,13 @@ retrieveCheap :: BupRepo -> Key -> FilePath -> Annex Bool retrieveCheap _ _ _ = return False retrieveEncrypted :: BupRepo -> (Cipher, Key) -> Key -> FilePath -> Annex Bool -retrieveEncrypted buprepo (cipher, enck) _ f = do - let params = bupParams "join" buprepo [Param $ bupRef enck] - liftIO $ catchBoolIO $ do - (pid, h) <- hPipeFrom "bup" $ toCommand params +retrieveEncrypted buprepo (cipher, enck) _ f = liftIO $ catchBoolIO $ + withHandle StdoutHandle createProcessSuccess p $ \h -> do withDecryptedContent cipher (L.hGetContents h) $ L.writeFile f - forceSuccess pid return True + where + params = bupParams "join" buprepo [Param $ bupRef enck] + p = proc "bup" $ toCommand params remove :: Key -> Annex Bool remove _ = do @@ -240,7 +245,7 @@ bupRef k | Git.Ref.legal True shown = shown | otherwise = "git-annex-" ++ showDigest (sha256 (fromString shown)) where - shown = show k + shown = key2file k bupLocal :: BupRepo -> Bool bupLocal = notElem ':' |