diff options
author | 2015-10-09 16:16:03 -0400 | |
---|---|---|
committer | 2015-10-09 16:16:03 -0400 | |
commit | 59e14fb081908f3d40eac6890cb668c088b86d92 (patch) | |
tree | 750482021e4aff738e1b27e37b8101043a41c3f0 | |
parent | e3eb0165dfec73d065b409d14ac83f855384b56b (diff) |
also generate a drop safety proof for move --from remote
-rw-r--r-- | Annex/NumCopies.hs | 4 | ||||
-rw-r--r-- | Command/Drop.hs | 2 | ||||
-rw-r--r-- | Command/Move.hs | 19 | ||||
-rw-r--r-- | doc/bugs/concurrent_drop--from_presence_checking_failures.mdwn | 19 |
4 files changed, 39 insertions, 5 deletions
diff --git a/Annex/NumCopies.hs b/Annex/NumCopies.hs index 2ddb460fd..64c78fca0 100644 --- a/Annex/NumCopies.hs +++ b/Annex/NumCopies.hs @@ -19,7 +19,7 @@ module Annex.NumCopies ( numCopiesCheck', verifyEnoughCopiesToDrop, verifiableCopies, - UnVerifiedCopy, + UnVerifiedCopy(..), ) where import Common.Annex @@ -115,7 +115,7 @@ verifyEnoughCopiesToDrop -> [UUID] -- repos to skip considering (generally untrusted remotes) -> [VerifiedCopy] -- copies already verified to exist -> [UnVerifiedCopy] -- places to check to see if they have copies - -> (SafeDropProof -> Annex a) -- action to perform to drop + -> (SafeDropProof -> Annex a) -- action to perform the drop -> Annex a -- action to perform when unable to drop -> Annex a verifyEnoughCopiesToDrop nolocmsg key removallock need skip preverified tocheck dropaction nodropaction = diff --git a/Command/Drop.hs b/Command/Drop.hs index 5bbaf11c6..5c5328618 100644 --- a/Command/Drop.hs +++ b/Command/Drop.hs @@ -120,7 +120,7 @@ performRemote key afile numcopies remote = do liftIO $ debugM "drop" $ unwords [ "Dropping from remote" , show remote - , "proof: " + , "proof:" , show proof ] ok <- Remote.removeKey remote key diff --git a/Command/Move.hs b/Command/Move.hs index bd1b6dd92..9a289d8b6 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010-2013 Joey Hess <id@joeyh.name> + - Copyright 2010-2015 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -16,6 +16,9 @@ import qualified Remote import Annex.UUID import Annex.Transfer import Logs.Presence +import Annex.NumCopies + +import System.Log.Logger (debugM) cmd :: Command cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $ @@ -170,6 +173,18 @@ fromPerform src move key afile = ifM (inAnnex key) Remote.retrieveKeyFile src key afile t p dispatch _ False = stop -- failed dispatch False True = next $ return True -- copy complete - dispatch True True = do -- finish moving + -- Finish by dropping from remote, taking care to verify that + -- the copy here has not been lost somehow. + -- (NumCopies is 1 since we're moving.) + dispatch True True = verifyEnoughCopiesToDrop "" key Nothing + (NumCopies 1) [] [] [UnVerifiedHere] dropremote faileddropremote + dropremote proof = do + liftIO $ debugM "drop" $ unwords + [ "Dropping from remote" + , show src + , "proof:" + , show proof + ] ok <- Remote.removeKey src key next $ Command.Drop.cleanupRemote key src ok + faileddropremote = error "Unable to drop from remote." diff --git a/doc/bugs/concurrent_drop--from_presence_checking_failures.mdwn b/doc/bugs/concurrent_drop--from_presence_checking_failures.mdwn index 22e50766a..de50ca431 100644 --- a/doc/bugs/concurrent_drop--from_presence_checking_failures.mdwn +++ b/doc/bugs/concurrent_drop--from_presence_checking_failures.mdwn @@ -346,3 +346,22 @@ A drops B keeps C keeps It can race other ways, but they all work out the same way essentially, due to the locking. </pre> + +# the bug, with moves + +`git annex move --from remote` is the same as a copy followed by drop --from, +so the same bug can occur then. + +But, the implementation differs from Command.Drop, so will also +need some changes. + +Command.Move.toPerform already locks local content for removal before +removing it, of course. So, that will interoperate fine with +concurrent drops/moves. Seems fine as-is. + +Command.Move.fromPerform simply needs to lock the local content +in place before dropping it from the remote. This satisfies the need +for 1 locked copy when dropping from a remote, and so is sufficent to +fix the bug. + +> done |