add removeKey action to Remote
Not implemented for any remotes yet; probably the git remote is the only one that will ever implement it.
This commit is contained in:
parent
beedf1da25
commit
b1abe59193
16 changed files with 22 additions and 2 deletions
|
@ -91,7 +91,7 @@ startRemote afile numcopies key remote = do
|
|||
-- Note that lockContentExclusive is called before checking if the key is
|
||||
-- present on enough remotes to allow removal. This avoids a scenario where two
|
||||
-- or more remotes are trying to remove a key at the same time, and each
|
||||
-- see the key is present on the other.
|
||||
-- sees the key is present on the other.
|
||||
performLocal :: Key -> AssociatedFile -> NumCopies -> Maybe Remote -> CommandPerform
|
||||
performLocal key afile numcopies knownpresentremote = lockContentExclusive key $ \contentlock -> do
|
||||
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
|
||||
|
|
|
@ -58,6 +58,7 @@ gen r _ c gc =
|
|||
, retrieveKeyFile = downloadKey
|
||||
, retrieveKeyFileCheap = downloadKeyCheap
|
||||
, removeKey = dropKey
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkKey
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -58,6 +58,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap buprepo
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = bupLocal buprepo
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -57,6 +57,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = ddarLocal ddarrepo
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -55,6 +55,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap dir chunkconfig
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = True
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -81,6 +81,7 @@ gen r u c gc
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = \_ _ _ -> return False
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = towhereis
|
||||
|
|
|
@ -111,6 +111,7 @@ gen' r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = \_ _ _ -> return False
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = repoCheap r
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -142,6 +142,7 @@ gen r u c gc
|
|||
, retrieveKeyFile = copyFromRemote new
|
||||
, retrieveKeyFileCheap = copyFromRemoteCheap new
|
||||
, removeKey = dropKey new
|
||||
, lockContent = Nothing
|
||||
, checkPresent = inAnnex new
|
||||
, checkPresentCheap = repoCheap r
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -55,6 +55,7 @@ gen r u c gc = new <$> remoteCost gc veryExpensiveRemoteCost
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap this
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -49,6 +49,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap hooktype
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -70,6 +70,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap o
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -81,6 +81,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Just (getWebUrls info)
|
||||
|
|
|
@ -72,6 +72,7 @@ gen r u c gc = do
|
|||
, retrieveKeyFile = retrieve u hdl
|
||||
, retrieveKeyFileCheap = \_ _ _ -> return False
|
||||
, removeKey = remove
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkKey u hdl
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -52,6 +52,7 @@ gen r _ c gc =
|
|||
, retrieveKeyFile = downloadKey
|
||||
, retrieveKeyFileCheap = downloadKeyCheap
|
||||
, removeKey = dropKey
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkKey
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -60,6 +60,7 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
|
|||
, retrieveKeyFile = retreiveKeyFileDummy
|
||||
, retrieveKeyFileCheap = retrieveCheap
|
||||
, removeKey = removeKeyDummy
|
||||
, lockContent = Nothing
|
||||
, checkPresent = checkPresentDummy
|
||||
, checkPresentCheap = False
|
||||
, whereisKey = Nothing
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
|
||||
module Types.Remote
|
||||
( RemoteConfigKey
|
||||
, RemoteConfig
|
||||
|
@ -72,8 +74,12 @@ data RemoteA a = Remote {
|
|||
-- Retrieves a key's contents to a tmp file, if it can be done cheaply.
|
||||
-- It's ok to create a symlink or hardlink.
|
||||
retrieveKeyFileCheap :: Key -> AssociatedFile -> FilePath -> a Bool,
|
||||
-- removes a key's contents (succeeds if the contents are not present)
|
||||
-- Removes a key's contents (succeeds if the contents are not present)
|
||||
removeKey :: Key -> a Bool,
|
||||
-- Uses locking to prevent removal of a key's contents,
|
||||
-- and runs the passed action while it's locked.
|
||||
-- This is optional; remotes do not have to support locking.
|
||||
lockContent :: forall r. Maybe (Key -> a r -> a r),
|
||||
-- Checks if a key is present in the remote.
|
||||
-- Throws an exception if the remote cannot be accessed.
|
||||
checkPresent :: Key -> a Bool,
|
||||
|
|
Loading…
Reference in a new issue