simplify code
This commit is contained in:
parent
3e0b210039
commit
067a9c70c7
2 changed files with 9 additions and 10 deletions
|
@ -491,28 +491,26 @@ sendAnnex key rollback sendobject = go =<< prepSendAnnex' key
|
||||||
-}
|
-}
|
||||||
prepSendAnnex :: Key -> Annex (Maybe (FilePath, Annex Bool))
|
prepSendAnnex :: Key -> Annex (Maybe (FilePath, Annex Bool))
|
||||||
prepSendAnnex key = withObjectLoc key $ \f -> do
|
prepSendAnnex key = withObjectLoc key $ \f -> do
|
||||||
|
let retval c = return $ Just (fromRawFilePath f, sameInodeCache f c)
|
||||||
cache <- Database.Keys.getInodeCaches key
|
cache <- Database.Keys.getInodeCaches key
|
||||||
cache' <- if null cache
|
if null cache
|
||||||
-- Since no inode cache is in the database, this
|
-- Since no inode cache is in the database, this
|
||||||
-- object is not currently unlocked. But that could
|
-- object is not currently unlocked. But that could
|
||||||
-- change while the transfer is in progress, so
|
-- change while the transfer is in progress, so
|
||||||
-- generate an inode cache for the starting
|
-- generate an inode cache for the starting
|
||||||
-- content.
|
-- content.
|
||||||
then maybeToList <$>
|
then maybe (return Nothing) (retval . (:[]))
|
||||||
withTSDelta (liftIO . genInodeCache f)
|
=<< withTSDelta (liftIO . genInodeCache f)
|
||||||
-- Verify that the object is not modified. Usually this
|
-- Verify that the object is not modified. Usually this
|
||||||
-- only has to check the inode cache, but if the cache
|
-- only has to check the inode cache, but if the cache
|
||||||
-- is somehow stale, it will fall back to verifying its
|
-- is somehow stale, it will fall back to verifying its
|
||||||
-- content.
|
-- content.
|
||||||
else withTSDelta (liftIO . genInodeCache f) >>= \case
|
else withTSDelta (liftIO . genInodeCache f) >>= \case
|
||||||
Just fc -> ifM (isUnmodified' key f fc cache)
|
Just fc -> ifM (isUnmodified' key f fc cache)
|
||||||
( return (fc:cache)
|
( retval (fc:cache)
|
||||||
, return []
|
, return Nothing
|
||||||
)
|
)
|
||||||
Nothing -> return []
|
Nothing -> return Nothing
|
||||||
return $ if null cache'
|
|
||||||
then Nothing
|
|
||||||
else Just (fromRawFilePath f, sameInodeCache f cache')
|
|
||||||
|
|
||||||
prepSendAnnex' :: Key -> Annex (Maybe (FilePath, Annex (Maybe String)))
|
prepSendAnnex' :: Key -> Annex (Maybe (FilePath, Annex (Maybe String)))
|
||||||
prepSendAnnex' key = prepSendAnnex key >>= \case
|
prepSendAnnex' key = prepSendAnnex key >>= \case
|
||||||
|
|
|
@ -14,7 +14,8 @@ import Annex.InodeSentinal
|
||||||
import Utility.InodeCache
|
import Utility.InodeCache
|
||||||
|
|
||||||
isUnmodifiedLowLevel :: (Key -> [InodeCache] -> Annex ()) -> Key -> RawFilePath -> InodeCache -> [InodeCache] -> Annex Bool
|
isUnmodifiedLowLevel :: (Key -> [InodeCache] -> Annex ()) -> Key -> RawFilePath -> InodeCache -> [InodeCache] -> Annex Bool
|
||||||
isUnmodifiedLowLevel addinodecaches key f fc ic = isUnmodifiedCheapLowLevel fc ic <||> expensivecheck
|
isUnmodifiedLowLevel addinodecaches key f fc ic =
|
||||||
|
isUnmodifiedCheapLowLevel fc ic <||> expensivecheck
|
||||||
where
|
where
|
||||||
expensivecheck = ifM (verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified key f)
|
expensivecheck = ifM (verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified key f)
|
||||||
( do
|
( do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue