summaryrefslogtreecommitdiff
path: root/Command/AddUrl.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-02 15:12:33 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-02 15:12:33 -0400
commitb38a482dd99a4f16c9752190e929b7726aba4c83 (patch)
tree5ea3ff8397d4207ce9db5cf5a963957acf747d07 /Command/AddUrl.hs
parent8e7728b312704f6f4cb84d81302c1518f0e85948 (diff)
addurl, importfeed: Changed to honor annex.largefiles settings, when the content of the url is downloaded. (Not when using --fast or --relaxed.)
importfeed just calls addurl functions, so inherits this from it. Note that addurl still generates a temp file, and uses that key to download the file. It just adds it to the work tree at the end when the file is small.
Diffstat (limited to 'Command/AddUrl.hs')
-rw-r--r--Command/AddUrl.hs34
1 files changed, 23 insertions, 11 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 78313f538..af2e04a62 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -29,6 +29,7 @@ import Types.KeySource
import Types.UrlContents
import Config
import Annex.Content.Direct
+import Annex.FileMatcher
import Logs.Location
import Utility.Metered
import qualified Annex.Transfer as Transfer
@@ -335,17 +336,28 @@ addSizeUrlKey :: Url.UrlInfo -> Key -> Key
addSizeUrlKey urlinfo key = key { keySize = Url.urlSize urlinfo }
cleanup :: UUID -> URLString -> FilePath -> Key -> Maybe FilePath -> Annex ()
-cleanup u url file key mtmp = do
- when (isJust mtmp) $
- logStatus key InfoPresent
- setUrlPresent u key url
- Command.Add.addLink file key Nothing
- whenM isDirect $ do
- void $ addAssociatedFile key file
- {- For moveAnnex to work in direct mode, the symlink
- - must already exist, so flush the queue. -}
- Annex.Queue.flush
- maybe noop (moveAnnex key) mtmp
+cleanup u url file key mtmp = case mtmp of
+ Nothing -> go
+ Just tmp -> do
+ largematcher <- largeFilesMatcher
+ ifM (checkFileMatcher largematcher file)
+ ( go
+ , do
+ liftIO $ renameFile tmp file
+ void $ Command.Add.addSmall file
+ )
+ where
+ go = do
+ when (isJust mtmp) $
+ logStatus key InfoPresent
+ setUrlPresent u key url
+ Command.Add.addLink file key Nothing
+ whenM isDirect $ do
+ void $ addAssociatedFile key file
+ {- For moveAnnex to work in direct mode, the symlink
+ - must already exist, so flush the queue. -}
+ Annex.Queue.flush
+ maybe noop (moveAnnex key) mtmp
nodownload :: URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
nodownload url urlinfo file