make storeKey throw exceptions
When storing content on remote fails, always display a reason why. Since the Storer used by special remotes already did, this mostly affects git remotes, but not entirely. For example, if git-lfs failed to connect to the endpoint, it used to silently return False.
This commit is contained in:
parent
b50ee9cd0c
commit
c1cd402081
34 changed files with 214 additions and 197 deletions
|
@ -126,8 +126,12 @@ toPerform dest removewhen key afile fastcheck isthere =
|
|||
Right False -> do
|
||||
showAction $ "to " ++ Remote.name dest
|
||||
ok <- notifyTransfer Upload afile $
|
||||
upload (Remote.uuid dest) key afile stdRetry $
|
||||
Remote.storeKey dest key afile
|
||||
upload (Remote.uuid dest) key afile stdRetry $ \p ->
|
||||
tryNonAsync (Remote.storeKey dest key afile p) >>= \case
|
||||
Left e -> do
|
||||
warning (show e)
|
||||
return False
|
||||
Right () -> return True
|
||||
if ok
|
||||
then finish False $
|
||||
Remote.logStatus dest key InfoPresent
|
||||
|
|
|
@ -40,6 +40,7 @@ import "crypto-api" Crypto.Random
|
|||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Map as M
|
||||
import Data.Either
|
||||
import Control.Concurrent.STM hiding (check)
|
||||
|
||||
cmd :: Command
|
||||
|
@ -217,11 +218,11 @@ test runannex mkr mkk =
|
|||
, check ("present " ++ show False) $ \r k ->
|
||||
whenwritable r $ present r k False
|
||||
, check "storeKey" $ \r k ->
|
||||
whenwritable r $ store r k
|
||||
whenwritable r $ isRight <$> tryNonAsync (store r k)
|
||||
, check ("present " ++ show True) $ \r k ->
|
||||
whenwritable r $ present r k True
|
||||
, check "storeKey when already present" $ \r k ->
|
||||
whenwritable r $ store r k
|
||||
whenwritable r $ isRight <$> tryNonAsync (store r k)
|
||||
, check ("present " ++ show True) $ \r k -> present r k True
|
||||
, check "retrieveKeyFile" $ \r k -> do
|
||||
lockContentForRemoval k removeAnnex
|
||||
|
@ -341,7 +342,7 @@ testUnavailable :: RunAnnex -> Annex (Maybe Remote) -> Annex Key -> [TestTree]
|
|||
testUnavailable runannex mkr mkk =
|
||||
[ check (== Right False) "removeKey" $ \r k ->
|
||||
Remote.removeKey r k
|
||||
, check (== Right False) "storeKey" $ \r k ->
|
||||
, check isLeft "storeKey" $ \r k ->
|
||||
Remote.storeKey r k (AssociatedFile Nothing) nullMeterUpdate
|
||||
, check (`notElem` [Right True, Right False]) "checkPresent" $ \r k ->
|
||||
Remote.checkPresent r k
|
||||
|
|
|
@ -52,10 +52,13 @@ start o key = startingCustomOutput key $ case fromToOptions o of
|
|||
toPerform :: Key -> AssociatedFile -> Remote -> CommandPerform
|
||||
toPerform key file remote = go Upload file $
|
||||
upload (uuid remote) key file stdRetry $ \p -> do
|
||||
ok <- Remote.storeKey remote key file p
|
||||
when ok $
|
||||
Remote.logStatus remote key InfoPresent
|
||||
return ok
|
||||
tryNonAsync (Remote.storeKey remote key file p) >>= \case
|
||||
Left e -> do
|
||||
warning (show e)
|
||||
return False
|
||||
Right () -> do
|
||||
Remote.logStatus remote key InfoPresent
|
||||
return True
|
||||
|
||||
fromPerform :: Key -> AssociatedFile -> Remote -> CommandPerform
|
||||
fromPerform key file remote = go Upload file $
|
||||
|
|
|
@ -38,10 +38,13 @@ start = do
|
|||
runner (TransferRequest direction remote key file)
|
||||
| direction == Upload = notifyTransfer direction file $
|
||||
upload (Remote.uuid remote) key file stdRetry $ \p -> do
|
||||
ok <- Remote.storeKey remote key file p
|
||||
when ok $
|
||||
Remote.logStatus remote key InfoPresent
|
||||
return ok
|
||||
tryNonAsync (Remote.storeKey remote key file p) >>= \case
|
||||
Left e -> do
|
||||
warning (show e)
|
||||
return False
|
||||
Right () -> do
|
||||
Remote.logStatus remote key InfoPresent
|
||||
return True
|
||||
| otherwise = notifyTransfer direction file $
|
||||
download (Remote.uuid remote) key file stdRetry $ \p ->
|
||||
getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key $ \t -> do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue