improve error message when download from non-chunked remote fails

Avoid "chunk retrieval failed" in this case, when it tries to fall back
to using chunks.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2020-05-21 14:44:40 -04:00
parent e63dcbf36c
commit c108fa16f1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -239,17 +239,17 @@ retrieveChunks retriever u chunkconfig encryptor basek dest basep sink
-- looking in the git-annex branch for chunk counts
-- that are likely not there.
getunchunked `catchNonAsync`
const (go =<< chunkKeysOnly u basek)
| otherwise = go =<< chunkKeys u chunkconfig basek
(\e -> go (Just e) =<< chunkKeysOnly u basek)
| otherwise = go Nothing =<< chunkKeys u chunkconfig basek
where
go ls = do
go pe ls = do
currsize <- liftIO $ catchMaybeIO $ getFileSize dest
let ls' = maybe ls (setupResume ls) currsize
if any null ls'
then noop -- dest is already complete
else firstavail Nothing currsize ls'
else firstavail pe currsize ls'
firstavail Nothing _ [] = giveup "chunk retrieval failed"
firstavail Nothing _ [] = giveup "unable to determine the chunks to use for this remote"
firstavail (Just e) _ [] = throwM e
firstavail pe currsize ([]:ls) = firstavail pe currsize ls
firstavail _ currsize ((k:ks):ls)