summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-31 12:19:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-31 12:19:00 -0400
commit79e8517738aca8e841e7cc0977d32a64a538bf21 (patch)
treeee47908be96a887d219aa77c951a0898e21e27de
parent95b50b5e919bccccca3ae666f4d5e9d1418ca396 (diff)
importfeed --force: re-download urls that have been seen before
-rw-r--r--Command/ImportFeed.hs24
-rw-r--r--doc/git-annex.mdwn2
2 files changed, 16 insertions, 10 deletions
diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs
index 27ccf07ff..7e59c556d 100644
--- a/Command/ImportFeed.hs
+++ b/Command/ImportFeed.hs
@@ -15,6 +15,7 @@ import qualified Data.Map as M
import Data.Char
import Common.Annex
+import qualified Annex
import Command
import qualified Utility.Url as Url
import Logs.Web
@@ -68,12 +69,15 @@ data Cache = Cache
}
getCache :: Maybe String -> Annex Cache
-getCache opttemplate = do
- showSideAction "checking known urls"
- us <- S.fromList <$> knownUrls
- return $ Cache us tmpl
+getCache opttemplate = ifM (Annex.getState Annex.force)
+ ( ret S.empty
+ , do
+ showSideAction "checking known urls"
+ ret =<< S.fromList <$> knownUrls
+ )
where
tmpl = Utility.Format.gen $ fromMaybe defaultTemplate opttemplate
+ ret s = return $ Cache s tmpl
findEnclosures :: URLString -> Annex (Maybe [ToDownload])
findEnclosures url = go =<< downloadFeed url
@@ -96,19 +100,21 @@ downloadFeed url = do
)
{- Avoids downloading any urls that are already known to be associated
- - with a file in the annex. -}
+ - with a file in the annex, unless forced. -}
downloadEnclosure :: Bool -> Cache -> ToDownload -> Annex ()
downloadEnclosure relaxed cache enclosure
- | S.member url (knownurls cache) = noop
- | otherwise = do
+ | S.member url (knownurls cache) =
+ whenM (Annex.getState Annex.force) go
+ | otherwise = go
+ where
+ url = location enclosure
+ go = do
dest <- liftIO $ feedFile (template cache) enclosure
showStart "addurl" dest
ifM (addUrlFile relaxed url dest)
( showEndOk
, showEndFail
)
- where
- url = location enclosure
defaultTemplate :: String
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 7b2a0bce5..1169c97ba 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -195,7 +195,7 @@ subdirectories).
Imports the contents of podcast feeds. Only downloads files whose
urls have not already been added to the repository before, so you can
delete, rename, etc the resulting files and repeated runs won't duplicate
- them.
+ them. (Use --force to force downloading files it's seen before.)
Use --template to control where the files are stored.
The default template is '${feedtitle}/${itemtitle}${extension}'