diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-09 18:42:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-09 18:42:29 -0400 |
commit | 0c893f8743bab81077e3ee0fed0993b746d7a269 (patch) | |
tree | b3ddc0665c28fadbfac58fbc43fc8a9dc85f3956 /Remote/Bup.hs | |
parent | 680e6839ee42c754a58f8e57bf15a8063a16c6bb (diff) |
Special remotes now all rollback storage of keys that get modified during the transfer, which can happen in direct mode.
Diffstat (limited to 'Remote/Bup.hs')
-rw-r--r-- | Remote/Bup.hs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs index 56253f5b8..2976ff086 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -121,16 +121,17 @@ bupSplitParams r buprepo k src = do (os ++ [Param "-n", Param (bupRef k)] ++ src) store :: Remote -> BupRepo -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool -store r buprepo k _f _p = sendAnnex k $ \src -> do +store r buprepo k _f _p = sendAnnex k (rollback k buprepo) $ \src -> do params <- bupSplitParams r buprepo k [File src] liftIO $ boolSystem "bup" params storeEncrypted :: Remote -> BupRepo -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool -storeEncrypted r buprepo (cipher, enck) k _p = sendAnnex k $ \src -> do - params <- bupSplitParams r buprepo enck [] - liftIO $ catchBoolIO $ - encrypt cipher (feedFile src) $ \h -> - pipeBup params (Just h) Nothing +storeEncrypted r buprepo (cipher, enck) k _p = + sendAnnex k (rollback enck buprepo) $ \src -> do + params <- bupSplitParams r buprepo enck [] + liftIO $ catchBoolIO $ + encrypt cipher (feedFile src) $ \h -> + pipeBup params (Just h) Nothing retrieve :: BupRepo -> Key -> AssociatedFile -> FilePath -> Annex Bool retrieve buprepo k _f d = do @@ -157,6 +158,20 @@ remove _ = do warning "content cannot be removed from bup remote" return False +{- Cannot revert having stored a key in bup, but at least the data for the + - key will be used for deltaing data of other keys stored later. + - + - We can, however, remove the git branch that bup created for the key. + -} +rollback :: Key -> BupRepo -> Annex () +rollback k bupr = go =<< liftIO (bup2GitRemote bupr) + where + go r + | Git.repoIsUrl r = void $ onBupRemote r boolSystem "git" params + | otherwise = void $ liftIO $ catchMaybeIO $ + boolSystem "git" $ Git.Command.gitCommandLine params r + params = [ Params "branch -D", Param (bupRef k) ] + {- Bup does not provide a way to tell if a given dataset is present - in a bup repository. One way it to check if the git repository has - a branch matching the name (as created by bup split -n). |