file:/// URLs can now be used with the web special remote.
This commit is contained in:
parent
452e6819d0
commit
62f50b2052
2 changed files with 15 additions and 5 deletions
|
@ -37,10 +37,15 @@ check url headers expected_size = handle <$> exists url headers
|
||||||
{- Checks that an url exists and could be successfully downloaded,
|
{- Checks that an url exists and could be successfully downloaded,
|
||||||
- also returning its size if available. -}
|
- also returning its size if available. -}
|
||||||
exists :: URLString -> Headers -> IO (Bool, Maybe Integer)
|
exists :: URLString -> Headers -> IO (Bool, Maybe Integer)
|
||||||
exists url headers =
|
exists url headers = case parseURI url of
|
||||||
case parseURI url of
|
Nothing -> return (False, Nothing)
|
||||||
Nothing -> return (False, Nothing)
|
Just u
|
||||||
Just u -> do
|
| uriScheme u == "file:" -> do
|
||||||
|
s <- catchMaybeIO $ getFileStatus (uriPath u)
|
||||||
|
return $ case s of
|
||||||
|
Nothing -> (False, Nothing)
|
||||||
|
Just stat -> (True, Just $ fromIntegral $ fileSize stat)
|
||||||
|
| otherwise -> do
|
||||||
r <- request u headers HEAD
|
r <- request u headers HEAD
|
||||||
case rspCode r of
|
case rspCode r of
|
||||||
(2,_,_) -> return (True, size r)
|
(2,_,_) -> return (True, size r)
|
||||||
|
@ -54,9 +59,13 @@ exists url headers =
|
||||||
- so is preferred.) Which program to use is determined at run time; it
|
- so is preferred.) Which program to use is determined at run time; it
|
||||||
- would not be appropriate to test at configure time and build support
|
- would not be appropriate to test at configure time and build support
|
||||||
- for only one in.
|
- for only one in.
|
||||||
|
-
|
||||||
|
- Curl is always used for file:// urls, as wget does not support them.
|
||||||
-}
|
-}
|
||||||
download :: URLString -> Headers -> [CommandParam] -> FilePath -> IO Bool
|
download :: URLString -> Headers -> [CommandParam] -> FilePath -> IO Bool
|
||||||
download url headers options file = ifM (inPath "wget") (wget , curl)
|
download url headers options file
|
||||||
|
| "file://" `isPrefixOf` url = curl
|
||||||
|
| otherwise = ifM (inPath "wget") (wget , curl)
|
||||||
where
|
where
|
||||||
headerparams = map (\h -> Param $ "--header=" ++ h) headers
|
headerparams = map (\h -> Param $ "--header=" ++ h) headers
|
||||||
wget = go "wget" $ headerparams ++ [Params "-c -O"]
|
wget = go "wget" $ headerparams ++ [Params "-c -O"]
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -11,6 +11,7 @@ git-annex (3.20121018) UNRELEASED; urgency=low
|
||||||
* Depend on and use the Haskell SafeSemaphore library, which provides
|
* Depend on and use the Haskell SafeSemaphore library, which provides
|
||||||
exception-safe versions of SampleVar and QSemN.
|
exception-safe versions of SampleVar and QSemN.
|
||||||
Thanks, Ben Gamari for an excellent patch set.
|
Thanks, Ben Gamari for an excellent patch set.
|
||||||
|
* file:/// URLs can now be used with the web special remote.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400
|
-- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue