aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-08-19 12:24:55 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-08-19 12:24:55 -0400
commit52f4a0722c3c6f71cea0666cba3f27adc085d629 (patch)
tree3789171e5fc0628d4fcd549309333ce1cd9eb9ee
parentbbd8b63d4768c51bb804dcf03a17fdd895997ab5 (diff)
importfeed --relaxed: Avoid hitting the urls of items in the feed.
-rw-r--r--Annex/Init.hs4
-rw-r--r--Command/AddUrl.hs2
-rw-r--r--Command/ImportFeed.hs4
-rw-r--r--Utility/Url.hs4
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/importfeed_--relaxed_fails_with_HEAD-rejecting_servers.mdwn2
-rw-r--r--doc/git-annex-addurl.mdwn3
7 files changed, 16 insertions, 4 deletions
diff --git a/Annex/Init.hs b/Annex/Init.hs
index fad533d13..5759adffc 100644
--- a/Annex/Init.hs
+++ b/Annex/Init.hs
@@ -138,8 +138,10 @@ probeCrippledFileSystem = do
createSymbolicLink f f2
nukeFile f2
preventWrite f
- -- Should be unable to write to the file, but some crippled
+ -- Should be unable to write to the file, unless
+ -- running as root, but some crippled
-- filesystems ignore write bit removals.
+ unlessM
not <$> catchBoolIO (writeFile f "2" >> return True)
#endif
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index adc0d3a1e..de3bff407 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -182,7 +182,7 @@ startWeb o s = go $ fromMaybe bad $ parseURI urlstring
regulardownload url = do
pathmax <- liftIO $ fileNameLengthLimit "."
urlinfo <- if relaxedOption o
- then pure $ Url.UrlInfo True Nothing Nothing
+ then pure Url.assumeUrlExists
else Url.withUrlOptions (Url.getUrlInfo urlstring)
file <- adjustFile o <$> case fileOption o of
Just f -> pure f
diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs
index 46e1b6dbe..d82d73447 100644
--- a/Command/ImportFeed.hs
+++ b/Command/ImportFeed.hs
@@ -172,7 +172,9 @@ performDownload opts cache todownload = case location todownload of
r <- Remote.claimingUrl url
if Remote.uuid r == webUUID || rawOption opts
then do
- urlinfo <- Url.withUrlOptions (Url.getUrlInfo url)
+ urlinfo <- if relaxedOption opts
+ then pure Url.assumeUrlExists
+ else Url.withUrlOptions (Url.getUrlInfo url)
maybeToList <$> addUrlFile (relaxedOption opts) url urlinfo f
else do
res <- tryNonAsync $ maybe
diff --git a/Utility/Url.hs b/Utility/Url.hs
index 90ca74eaf..976fe975d 100644
--- a/Utility/Url.hs
+++ b/Utility/Url.hs
@@ -20,6 +20,7 @@ module Utility.Url (
exists,
UrlInfo(..),
getUrlInfo,
+ assumeUrlExists,
download,
downloadQuiet,
parseURIRelaxed
@@ -104,6 +105,9 @@ data UrlInfo = UrlInfo
, urlSuggestedFile :: Maybe FilePath
}
+assumeUrlExists :: UrlInfo
+assumeUrlExists = UrlInfo True Nothing Nothing
+
{- Checks that an url exists and could be successfully downloaded,
- also returning its size and suggested filename if available. -}
getUrlInfo :: URLString -> UrlOptions -> IO UrlInfo
diff --git a/debian/changelog b/debian/changelog
index 1bba9d806..b81a53328 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,7 @@ git-annex (5.20150813) UNRELEASED; urgency=medium
http.
* Avoid building the assistant on the hurd, since an inotify equivilant
is not yet implemented in git-annex for the hurd.
+ * importfeed --relaxed: Avoid hitting the urls of items in the feed.
-- Joey Hess <id@joeyh.name> Wed, 12 Aug 2015 14:31:01 -0400
diff --git a/doc/bugs/importfeed_--relaxed_fails_with_HEAD-rejecting_servers.mdwn b/doc/bugs/importfeed_--relaxed_fails_with_HEAD-rejecting_servers.mdwn
index 5a52af36b..f7b6199ff 100644
--- a/doc/bugs/importfeed_--relaxed_fails_with_HEAD-rejecting_servers.mdwn
+++ b/doc/bugs/importfeed_--relaxed_fails_with_HEAD-rejecting_servers.mdwn
@@ -34,3 +34,5 @@ I ran into this bug trying to importfeed various BBC podcasts. For instance:
### What version of git-annex are you using? On what operating system?
git-annex version: 5.20150731-1 on a quite up-to-date debian unstable.
+
+> Thanks for a nice test case. [[fixed|done]] --[[Joey]]
diff --git a/doc/git-annex-addurl.mdwn b/doc/git-annex-addurl.mdwn
index 888f6ac31..1503a284e 100644
--- a/doc/git-annex-addurl.mdwn
+++ b/doc/git-annex-addurl.mdwn
@@ -25,7 +25,8 @@ be used to get better filenames.
* `--fast`
- Avoid immediately downloading the url.
+ Avoid immediately downloading the url. The url is still checked
+ (via HEAD) to verify that it exists, and to get its size if possible.
* `--relaxed`