lockContent for tahoe

Trivial since git-annex cannot remove, but do an active checkKey verification
anyway, in case the data was lost somehow.

This commit was sponsored by Ryan Newton on Patreon.
This commit is contained in:
Joey Hess 2020-06-26 14:23:21 -04:00
parent 76721b62dd
commit 8b22e0bf37
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 14 additions and 3 deletions

View file

@ -16,7 +16,7 @@ git-annex (8.20200618) UNRELEASED; urgency=medium
* Made several special remotes support locking content on them while * Made several special remotes support locking content on them while
dropping, which allows dropping from another special remote when dropping, which allows dropping from another special remote when
the content will only remain on a special remote of these types: the content will only remain on a special remote of these types:
S3 (with versioning=yes), git-lfs S3 (with versioning=yes), git-lfs, tahoe
-- Joey Hess <id@joeyh.name> Thu, 18 Jun 2020 12:21:14 -0400 -- Joey Hess <id@joeyh.name> Thu, 18 Jun 2020 12:21:14 -0400

View file

@ -13,7 +13,7 @@
- -
- Tahoe has its own encryption, so git-annex's encryption is not used. - Tahoe has its own encryption, so git-annex's encryption is not used.
- -
- Copyright 2014-2019 Joey Hess <id@joeyh.name> - Copyright 2014-2020 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -31,6 +31,7 @@ import Annex.Common
import Types.Remote import Types.Remote
import Types.Creds import Types.Creds
import Types.ProposedAccepted import Types.ProposedAccepted
import Types.NumCopies
import qualified Git import qualified Git
import Config import Config
import Config.Cost import Config.Cost
@ -91,7 +92,7 @@ gen r u rc gc rs = do
-- Tahoe cryptographically verifies content. -- Tahoe cryptographically verifies content.
, retrievalSecurityPolicy = RetrievalAllKeysSecure , retrievalSecurityPolicy = RetrievalAllKeysSecure
, removeKey = remove , removeKey = remove
, lockContent = Nothing , lockContent = Just $ lockKey u rs hdl
, checkPresent = checkKey rs hdl , checkPresent = checkKey rs hdl
, checkPresentCheap = False , checkPresentCheap = False
, exportActions = exportUnsupported , exportActions = exportUnsupported
@ -153,6 +154,16 @@ retrieve rs hdl k _f d _p = do
remove :: Key -> Annex () remove :: Key -> Annex ()
remove _k = giveup "content cannot be removed from tahoe remote" remove _k = giveup "content cannot be removed from tahoe remote"
-- Since content cannot be removed from tahoe (by git-annex),
-- nothing needs to be done to lock content there, except for checking that
-- it is actually present.
lockKey :: UUID -> RemoteStateHandle -> TahoeHandle -> Key -> (VerifiedCopy -> Annex a) -> Annex a
lockKey u rs hrl k callback =
ifM (checkKey rs hrl k)
( withVerifiedCopy LockedCopy u (return True) callback
, giveup $ "content seems to be missing from tahoe remote"
)
checkKey :: RemoteStateHandle -> TahoeHandle -> Key -> Annex Bool checkKey :: RemoteStateHandle -> TahoeHandle -> Key -> Annex Bool
checkKey rs hdl k = go =<< getCapability rs k checkKey rs hdl k = go =<< getCapability rs k
where where