aboutsummaryrefslogtreecommitdiff
path: root/Remote/Bup.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-06 14:28:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-06 14:28:36 -0400
commitefe30b0e402200a017d275ea2c93e0ceb8e3ec42 (patch)
treef4c9248e003badce98c34ac0f2171b2ae9dd9ebf /Remote/Bup.hs
parentcc2606ce542e04c22cf229d536ad621f9e25c12d (diff)
run Preparer to get Remover and CheckPresent actions
This will allow special remotes to eg, open a http connection and reuse it, while checking if chunks are present, or removing chunks. S3 and WebDAV both need this to support chunks with reasonable speed. Note that a special remote might want to cache a http connection across multiple requests. A simple case of this is that CheckPresent is typically called before Store or Remove. A remote using this interface can certianly use a Preparer that eg, uses a MVar to cache a http connection. However, it's up to the remote to then deal with things like stale or stalled http connections when eg, doing a series of downloads from a remote and other places. There could be long delays between calls to a remote, which could lead to eg, http connection stalls; the machine might even move to a new network, etc. It might be nice to improve this interface later to allow the simple case without needing to handle the full complex case. One way to do it would be to have a `Transaction SpecialRemote cache`, where SpecialRemote contains methods for Storer, Retriever, Remover, and CheckPresent, that all expect to be passed a `cache`.
Diffstat (limited to 'Remote/Bup.hs')
-rw-r--r--Remote/Bup.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Remote/Bup.hs b/Remote/Bup.hs
index 2e68f30ef..80fffc056 100644
--- a/Remote/Bup.hs
+++ b/Remote/Bup.hs
@@ -57,8 +57,8 @@ gen r u c gc = do
, storeKey = storeKeyDummy
, retrieveKeyFile = retreiveKeyFileDummy
, retrieveKeyFileCheap = retrieveCheap buprepo
- , removeKey = remove buprepo
- , checkPresent = checkKey r bupr'
+ , removeKey = removeKeyDummy
+ , checkPresent = checkPresentDummy
, checkPresentCheap = bupLocal buprepo
, whereisKey = Nothing
, remoteFsck = Nothing
@@ -76,6 +76,8 @@ gen r u c gc = do
return $ Just $ specialRemote' specialcfg c
(simplyPrepare $ store this buprepo)
(simplyPrepare $ retrieve buprepo)
+ (simplyPrepare $ remove buprepo)
+ (simplyPrepare $ checkKey r bupr')
this
where
buprepo = fromMaybe (error "missing buprepo") $ remoteAnnexBupRepo gc
@@ -146,7 +148,7 @@ retrieveCheap _ _ _ = return False
-
- We can, however, remove the git branch that bup created for the key.
-}
-remove :: BupRepo -> Key -> Annex Bool
+remove :: BupRepo -> Remover
remove buprepo k = do
go =<< liftIO (bup2GitRemote buprepo)
warning "content cannot be completely removed from bup remote"
@@ -163,7 +165,7 @@ remove buprepo k = do
- 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).
-}
-checkKey :: Git.Repo -> Git.Repo -> Key -> Annex Bool
+checkKey :: Git.Repo -> Git.Repo -> CheckPresent
checkKey r bupr k
| Git.repoIsUrl bupr = do
showChecking r