avoid watchFileSize running backward

This is groundwork for using watchFileSize for downloads from external
special remotes.

In Annex.Content.downloadUrl, this potentially avoids jitter in the
progress meter. When downloading with conduit, the meter gets updated based
on both the size of the file, and on the data flowing through conduit.
If that has not yet been flushed to the file, it seems possible for the
meter to run backwards when meter is updated with the file size.
It's probably only a few kb of jitter, so may not be visible.

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2024-01-19 14:11:27 -04:00
parent 856c28508d
commit 703a70cafa
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 41 additions and 15 deletions

View file

@ -753,7 +753,7 @@ downloadUrl listfailedurls k p iv urls file uo =
-- download command is used.
meteredFile file (Just p) k (go urls [])
where
go (u:us) errs = Url.download' p iv u file uo >>= \case
go (u:us) errs p' = Url.download' p' iv u file uo >>= \case
Right () -> return True
Left err -> do
-- If the incremental verifier was fed anything
@ -765,9 +765,9 @@ downloadUrl listfailedurls k p iv urls file uo =
Just n | n > 0 -> unableIncrementalVerifier iv'
_ -> noop
Nothing -> noop
go us ((u, err) : errs)
go [] [] = return False
go [] errs@((_, err):_) = do
go us ((u, err) : errs) p'
go [] [] _ = return False
go [] errs@((_, err):_) _ = do
if listfailedurls
then warning $ UnquotedString $
unlines $ flip map errs $ \(u, err') ->