better indicate when special remotes do not support renameExport
Avoid a warning message when renameExport is not supported, and just fallback to deleting with a subsequent re-upload. Especially needed for importtree remotes, where renameExport needs to be disabled. This changes the external special remote protocol, but in a backwards-compatible way. A reply of UNSUPPORTED-REQUEST to an older version of git-annex will cause it to make renameExport return False.
This commit is contained in:
parent
c755788256
commit
2912429640
11 changed files with 62 additions and 53 deletions
|
@ -307,25 +307,28 @@ removeExportDirectoryM external dir = safely $
|
|||
where
|
||||
req = REMOVEEXPORTDIRECTORY dir
|
||||
|
||||
renameExportM :: External -> Key -> ExportLocation -> ExportLocation -> Annex Bool
|
||||
renameExportM external k src dest = safely $
|
||||
renameExportM :: External -> Key -> ExportLocation -> ExportLocation -> Annex (Maybe Bool)
|
||||
renameExportM external k src dest = safely' (Just False) $
|
||||
handleRequestExport external src req k Nothing $ \resp -> case resp of
|
||||
RENAMEEXPORT_SUCCESS k'
|
||||
| k' == k -> result True
|
||||
| k' == k -> result (Just True)
|
||||
RENAMEEXPORT_FAILURE k'
|
||||
| k' == k -> result False
|
||||
UNSUPPORTED_REQUEST -> result False
|
||||
| k' == k -> result (Just False)
|
||||
UNSUPPORTED_REQUEST -> result Nothing
|
||||
_ -> Nothing
|
||||
where
|
||||
req sk = RENAMEEXPORT sk dest
|
||||
|
||||
safely :: Annex Bool -> Annex Bool
|
||||
safely a = go =<< tryNonAsync a
|
||||
safely = safely' False
|
||||
|
||||
safely' :: a -> Annex a -> Annex a
|
||||
safely' onerr a = go =<< tryNonAsync a
|
||||
where
|
||||
go (Right r) = return r
|
||||
go (Left e) = do
|
||||
toplevelWarning False (show e)
|
||||
return False
|
||||
return onerr
|
||||
|
||||
{- Sends a Request to the external remote, and waits for it to generate
|
||||
- a Response. That is fed into the responsehandler, which should return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue