aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-10 19:23:23 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-10 19:23:46 -0400
commit17fed709c83de69c5bdf190b80eaa875fe6c9c7e (patch)
tree5b8f600af3314f47b621bd637530422295cd4b24
parent9030f684521ce8db3e9cd6a4e2a10f4edce7bfee (diff)
addurl --fast: Verifies that the url can be downloaded (only getting its head), and records the size in the key.
-rw-r--r--Backend/URL.hs8
-rw-r--r--Command/AddUrl.hs8
-rw-r--r--debian/changelog2
3 files changed, 14 insertions, 4 deletions
diff --git a/Backend/URL.hs b/Backend/URL.hs
index 6406095ca..b3411bac5 100644
--- a/Backend/URL.hs
+++ b/Backend/URL.hs
@@ -24,5 +24,9 @@ backend = Backend {
fsckKey = Nothing
}
-fromUrl :: String -> Key
-fromUrl url = stubKey { keyName = url, keyBackendName = "URL" }
+fromUrl :: String -> Maybe Integer -> Key
+fromUrl url size = stubKey
+ { keyName = url
+ , keyBackendName = "URL"
+ , keySize = size
+ }
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 496b9f2e8..40e3a0e98 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -15,6 +15,7 @@ import qualified Backend
import qualified Command.Add
import qualified Annex
import qualified Backend.URL
+import qualified Utility.Url as Url
import Annex.Content
import Logs.Web
import qualified Option
@@ -55,7 +56,7 @@ perform url file = ifAnnexed file addurl geturl
download :: String -> FilePath -> CommandPerform
download url file = do
showAction $ "downloading " ++ url ++ " "
- let dummykey = Backend.URL.fromUrl url
+ let dummykey = Backend.URL.fromUrl url Nothing
tmp <- fromRepo $ gitAnnexTmpLocation dummykey
liftIO $ createDirectoryIfMissing True (parentDir tmp)
stopUnless (downloadUrl [url] tmp) $ do
@@ -70,7 +71,10 @@ download url file = do
nodownload :: String -> FilePath -> CommandPerform
nodownload url file = do
- let key = Backend.URL.fromUrl url
+ (exists, size) <- liftIO $ Url.exists url
+ unless exists $
+ error $ "unable to access url: " ++ url
+ let key = Backend.URL.fromUrl url size
setUrlPresent key url
next $ Command.Add.cleanup file key False
diff --git a/debian/changelog b/debian/changelog
index 36034f2ae..f13797272 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,8 @@ git-annex (3.20120124) UNRELEASED; urgency=low
* Fix teardown of stale cached ssh connections.
* When checking that an url has a key, verify that the Content-Length,
if available, matches the size of the key.
+ * addurl --fast: Verifies that the url can be downloaded (only getting
+ its head), and records the size in the key.
-- Joey Hess <joeyh@debian.org> Tue, 24 Jan 2012 16:21:55 -0400