convert renameExport to throw exception

Finishes the transition to make remote methods throw exceptions, rather
than silently hide them.

A bit on the fence about this one, because when renameExport fails,
it falls back to deleting instead, and so does the user care why it failed?

However, it did let me clean up several places in the code.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2020-05-15 15:05:52 -04:00
parent 00448349de
commit 6361074174
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 64 additions and 89 deletions

View file

@ -396,13 +396,13 @@ startMoveFromTempName r db ek f = do
performRename :: Remote -> ExportHandle -> ExportKey -> ExportLocation -> ExportLocation -> CommandPerform
performRename r db ek src dest =
renameExport (exportActions r) (asKey ek) src dest >>= \case
Just True -> next $ cleanupRename r db ek src dest
Just False -> do
warning "rename failed; deleting instead"
tryNonAsync (renameExport (exportActions r) (asKey ek) src dest) >>= \case
Right (Just ()) -> next $ cleanupRename r db ek src dest
Left err -> do
warning $ "rename failed (" ++ show err ++ "); deleting instead"
fallbackdelete
-- Remote does not support renaming, so don't warn about it.
Nothing -> fallbackdelete
-- remote does not support renaming
Right Nothing -> fallbackdelete
where
fallbackdelete = performUnexport r db [ek] src