addurl: Include filename in --json-progress output when known.
This commit is contained in:
parent
e5a8d5effa
commit
38ddd6072d
3 changed files with 19 additions and 3 deletions
|
@ -10,6 +10,7 @@ git-annex (6.20180720) UNRELEASED; urgency=medium
|
|||
for the git-annex branch instead of the usual "update".
|
||||
* Fix wrong sorting of remotes when using -J, it was sorting by uuid,
|
||||
rather than cost.
|
||||
* addurl: Include filename in --json-progress output.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Tue, 31 Jul 2018 12:14:11 -0400
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ checkUrl r o u = do
|
|||
where
|
||||
|
||||
go _ (Left e) = void $ commandAction $ do
|
||||
showStart' "addurl" (Just u)
|
||||
showStartAddUrl u o
|
||||
warning (show e)
|
||||
next $ next $ return False
|
||||
go deffile (Right (UrlContents sz mf)) = do
|
||||
|
@ -148,7 +148,7 @@ startRemote :: Remote -> AddUrlOptions -> FilePath -> URLString -> Maybe Integer
|
|||
startRemote r o file uri sz = do
|
||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||
let file' = joinPath $ map (truncateFilePath pathmax) $ splitDirectories file
|
||||
showStart' "addurl" (Just uri)
|
||||
showStartAddUrl uri o
|
||||
showNote $ "from " ++ Remote.name r
|
||||
showDestinationFile file'
|
||||
next $ performRemote r o uri file' sz
|
||||
|
@ -192,7 +192,7 @@ startWeb o urlstring = go $ fromMaybe bad $ parseURI urlstring
|
|||
bad = fromMaybe (giveup $ "bad url " ++ urlstring) $
|
||||
Url.parseURIRelaxed $ urlstring
|
||||
go url = do
|
||||
showStart' "addurl" (Just urlstring)
|
||||
showStartAddUrl urlstring o
|
||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||
urlinfo <- if relaxedOption (downloadOptions o)
|
||||
then pure Url.assumeUrlExists
|
||||
|
@ -311,6 +311,15 @@ downloadWeb o url urlinfo file =
|
|||
warning $ dest ++ " already exists; not overwriting"
|
||||
return Nothing
|
||||
|
||||
{- The destination file is not known at start time unless the user provided
|
||||
- a filename. It's not displayed then for output consistency,
|
||||
- but is added to the json when available. -}
|
||||
showStartAddUrl url o = do
|
||||
showStart' "addurl" (Just url)
|
||||
case fileOption (downloadOptions o) of
|
||||
Nothing -> noop
|
||||
Just file -> maybeShowJSON $ JSONChunk [("file", file)]
|
||||
|
||||
showDestinationFile :: FilePath -> Annex ()
|
||||
showDestinationFile file = do
|
||||
showNote ("to " ++ file)
|
||||
|
|
|
@ -11,3 +11,9 @@ $> git annex addurl --file bigone --json --json-progress https://s3.amazonaws.co
|
|||
Thanks in advance
|
||||
|
||||
[[!meta author=yoh]]
|
||||
|
||||
> In general addurl doesn't know the filename until after it's downloaded
|
||||
> the url (due to running youtube-dl on html urls), but when --file
|
||||
> or --batch --with-files is used, it does know the filename early.
|
||||
> So, made the json-progress include the filename when it's known.
|
||||
> [[done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue