diff options
author | 2015-10-08 16:55:11 -0400 | |
---|---|---|
committer | 2015-10-08 16:55:11 -0400 | |
commit | d5494842274030d21356c7492e6de5969173c34d (patch) | |
tree | a1c25eacba4e6b98b0b1bf275a89ecc7ea0e20d2 /Annex/Content.hs | |
parent | 55fb90edfc8732b08bea9239a6f4a471ac7867c3 (diff) |
add VerifiedCopy data type
There should be no behavior changes in this commit, it just adds a more
expressive data type and adjusts code that had been passing around a [UUID]
or sometimes a Maybe Remote to instead use [VerifiedCopy].
Although, since some functions were taking two different [UUID] lists,
there's some potential for me to have gotten it horribly wrong.
Diffstat (limited to 'Annex/Content.hs')
-rw-r--r-- | Annex/Content.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index 8fbb49ce6..e45d9ea05 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -67,6 +67,8 @@ import Messages.Progress import qualified Types.Remote import qualified Types.Backend import qualified Backend +import Types.NumCopies +import Annex.UUID {- Checks if a given key's content is currently present. -} inAnnex :: Key -> Annex Bool @@ -178,8 +180,10 @@ contentLockFile key = Just <$> calcRepo (gitAnnexContentLock key) - Note that, in direct mode, nothing prevents the user from directly - editing or removing the content, even while it's locked by this. -} -lockContentShared :: Key -> Annex a -> Annex a -lockContentShared = lockContentUsing lock +lockContentShared :: Key -> (VerifiedCopy -> Annex a) -> Annex a +lockContentShared key a = lockContentUsing lock key $ do + u <- getUUID + a (VerifiedCopyLock u (return ())) where #ifndef mingw32_HOST_OS lock contentfile Nothing = liftIO $ tryLockShared Nothing contentfile @@ -195,7 +199,7 @@ newtype ContentLockExclusive = ContentLockExclusive Key -} lockContentExclusive :: Key -> (ContentLockExclusive -> Annex a) -> Annex a lockContentExclusive key a = lockContentUsing lock key $ - a $ ContentLockExclusive key + a (ContentLockExclusive key) where #ifndef mingw32_HOST_OS {- Since content files are stored with the write bit disabled, have @@ -238,7 +242,7 @@ lockContentUsing locker key a = do bracket (lock contentfile lockfile) (unlock lockfile) - (const $ a) + (const a) where alreadylocked = error "content is locked" failedtolock e = error $ "failed to lock content: " ++ show e |