diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-10-09 15:48:02 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-10-09 15:48:02 -0400 |
commit | 3c43af79d56a25bfff3eae1c1342c9a308223347 (patch) | |
tree | e52a095b8963ca42d6530d40bee5858ea8bfcf3c /Annex | |
parent | e36bfabb0e56087771d385a9f4ecdb342f1f14db (diff) |
fix local dropping to not require extra locking of copies, but only that the local copy be locked for removal
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 15 | ||||
-rw-r--r-- | Annex/NumCopies.hs | 13 |
2 files changed, 14 insertions, 14 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 40c78fd34..0dc47d9e2 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -13,7 +13,8 @@ module Annex.Content ( inAnnexSafe, inAnnexCheck, lockContentShared, - lockContentExclusive, + lockContentForRemoval, + ContentRemovalLock, getViaTmp, getViaTmp', checkDiskSpaceToGet, @@ -192,14 +193,12 @@ lockContentShared key a = lockContentUsing lock key $ do lock = winLocker lockShared #endif -newtype ContentLockExclusive = ContentLockExclusive Key - {- Exclusively locks content, while performing an action that - might remove it. -} -lockContentExclusive :: Key -> (ContentLockExclusive -> Annex a) -> Annex a -lockContentExclusive key a = lockContentUsing lock key $ - a (ContentLockExclusive key) +lockContentForRemoval :: Key -> (ContentRemovalLock -> Annex a) -> Annex a +lockContentForRemoval key a = lockContentUsing lock key $ + a (ContentRemovalLock key) where #ifndef mingw32_HOST_OS {- Since content files are stored with the write bit disabled, have @@ -547,8 +546,8 @@ cleanObjectLoc key cleaner = do - In direct mode, deletes the associated files or files, and replaces - them with symlinks. -} -removeAnnex :: ContentLockExclusive -> Annex () -removeAnnex (ContentLockExclusive key) = withObjectLoc key remove removedirect +removeAnnex :: ContentRemovalLock -> Annex () +removeAnnex (ContentRemovalLock key) = withObjectLoc key remove removedirect where remove file = cleanObjectLoc key $ do secureErase file diff --git a/Annex/NumCopies.hs b/Annex/NumCopies.hs index b51d3815b..2ddb460fd 100644 --- a/Annex/NumCopies.hs +++ b/Annex/NumCopies.hs @@ -104,12 +104,13 @@ data UnVerifiedCopy = UnVerifiedRemote Remote | UnVerifiedHere deriving (Ord, Eq) {- Verifies that enough copies of a key exist amoung the listed remotes, - - running an action with a proof if so, and printing an informative - - message if not. + - to safely drop it, running an action with a proof if so, and + - printing an informative message if not. -} verifyEnoughCopiesToDrop :: String -- message to print when there are no known locations -> Key + -> Maybe ContentRemovalLock -> NumCopies -> [UUID] -- repos to skip considering (generally untrusted remotes) -> [VerifiedCopy] -- copies already verified to exist @@ -117,19 +118,19 @@ verifyEnoughCopiesToDrop -> (SafeDropProof -> Annex a) -- action to perform to drop -> Annex a -- action to perform when unable to drop -> Annex a -verifyEnoughCopiesToDrop nolocmsg key need skip preverified tocheck dropaction nodropaction = +verifyEnoughCopiesToDrop nolocmsg key removallock need skip preverified tocheck dropaction nodropaction = helper [] [] preverified (nub tocheck) where helper bad missing have [] = do - p <- liftIO $ mkSafeDropProof need have + p <- liftIO $ mkSafeDropProof need have removallock case p of Right proof -> dropaction proof Left stillhave -> do notEnoughCopies key need stillhave (skip++missing) bad nolocmsg nodropaction helper bad missing have (c:cs) - | isSafeDrop need have = do - p <- liftIO $ mkSafeDropProof need have + | isSafeDrop need have removallock = do + p <- liftIO $ mkSafeDropProof need have removallock case p of Right proof -> dropaction proof Left stillhave -> helper bad missing stillhave (c:cs) |