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".
|
for the git-annex branch instead of the usual "update".
|
||||||
* Fix wrong sorting of remotes when using -J, it was sorting by uuid,
|
* Fix wrong sorting of remotes when using -J, it was sorting by uuid,
|
||||||
rather than cost.
|
rather than cost.
|
||||||
|
* addurl: Include filename in --json-progress output.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Tue, 31 Jul 2018 12:14:11 -0400
|
-- Joey Hess <id@joeyh.name> Tue, 31 Jul 2018 12:14:11 -0400
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ checkUrl r o u = do
|
||||||
where
|
where
|
||||||
|
|
||||||
go _ (Left e) = void $ commandAction $ do
|
go _ (Left e) = void $ commandAction $ do
|
||||||
showStart' "addurl" (Just u)
|
showStartAddUrl u o
|
||||||
warning (show e)
|
warning (show e)
|
||||||
next $ next $ return False
|
next $ next $ return False
|
||||||
go deffile (Right (UrlContents sz mf)) = do
|
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
|
startRemote r o file uri sz = do
|
||||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||||
let file' = joinPath $ map (truncateFilePath pathmax) $ splitDirectories file
|
let file' = joinPath $ map (truncateFilePath pathmax) $ splitDirectories file
|
||||||
showStart' "addurl" (Just uri)
|
showStartAddUrl uri o
|
||||||
showNote $ "from " ++ Remote.name r
|
showNote $ "from " ++ Remote.name r
|
||||||
showDestinationFile file'
|
showDestinationFile file'
|
||||||
next $ performRemote r o uri file' sz
|
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) $
|
bad = fromMaybe (giveup $ "bad url " ++ urlstring) $
|
||||||
Url.parseURIRelaxed $ urlstring
|
Url.parseURIRelaxed $ urlstring
|
||||||
go url = do
|
go url = do
|
||||||
showStart' "addurl" (Just urlstring)
|
showStartAddUrl urlstring o
|
||||||
pathmax <- liftIO $ fileNameLengthLimit "."
|
pathmax <- liftIO $ fileNameLengthLimit "."
|
||||||
urlinfo <- if relaxedOption (downloadOptions o)
|
urlinfo <- if relaxedOption (downloadOptions o)
|
||||||
then pure Url.assumeUrlExists
|
then pure Url.assumeUrlExists
|
||||||
|
@ -311,6 +311,15 @@ downloadWeb o url urlinfo file =
|
||||||
warning $ dest ++ " already exists; not overwriting"
|
warning $ dest ++ " already exists; not overwriting"
|
||||||
return Nothing
|
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 :: FilePath -> Annex ()
|
||||||
showDestinationFile file = do
|
showDestinationFile file = do
|
||||||
showNote ("to " ++ file)
|
showNote ("to " ++ file)
|
||||||
|
|
|
@ -11,3 +11,9 @@ $> git annex addurl --file bigone --json --json-progress https://s3.amazonaws.co
|
||||||
Thanks in advance
|
Thanks in advance
|
||||||
|
|
||||||
[[!meta author=yoh]]
|
[[!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