diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-02 15:12:33 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-02 15:12:33 -0400 |
commit | b38a482dd99a4f16c9752190e929b7726aba4c83 (patch) | |
tree | 5ea3ff8397d4207ce9db5cf5a963957acf747d07 | |
parent | 8e7728b312704f6f4cb84d81302c1518f0e85948 (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.
-rw-r--r-- | Command/Add.hs | 16 | ||||
-rw-r--r-- | Command/AddUrl.hs | 34 | ||||
-rw-r--r-- | Command/Import.hs | 2 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 5 | ||||
-rw-r--r-- | doc/todo/make_addurl_respect_annex.largefiles_option.mdwn | 2 |
6 files changed, 41 insertions, 21 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index 4ae97b6e3..27c11eab4 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -73,18 +73,18 @@ seek o = allowConcurrentOutput $ do startSmall :: FilePath -> CommandStart startSmall file = do showStart "add" file - next $ performSmall file + next $ next $ addSmall file -performSmall :: FilePath -> CommandPerform -performSmall file = do +addSmall :: FilePath -> Annex Bool +addSmall file = do showNote "non-large file; adding content to git repository" - performAdd file + addFile file -performAdd :: FilePath -> CommandPerform -performAdd file = do +addFile :: FilePath -> Annex Bool +addFile file = do ps <- forceParams Annex.Queue.addCommand "add" (ps++[Param "--"]) [file] - next $ return True + return True {- The add subcommand annexes a file, generating a key for it using a - backend, and then moving it into the annex directory and setting up @@ -101,7 +101,7 @@ start file = ifAnnexed file addpresent add | otherwise -> do showStart "add" file next $ if isSymbolicLink s - then performAdd file + then next $ addFile file else perform file addpresent key = ifM isDirect ( do 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 diff --git a/Command/Import.hs b/Command/Import.hs index 3887ea57b..7e8ce3b7a 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -129,7 +129,7 @@ start largematcher mode (srcfile, destfile) = else moveFile srcfile destfile ifM (checkFileMatcher largematcher destfile) ( Command.Add.perform destfile - , Command.Add.performSmall destfile + , next $ Command.Add.addSmall destfile ) notoverwriting why = do warning $ "not overwriting existing " ++ destfile ++ " " ++ why diff --git a/debian/changelog b/debian/changelog index 144e2c907..42295c91d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,9 @@ git-annex (5.20151117) UNRELEASED; urgency=medium them. Instead, a mode such as 664 is used in this case. * tahoe: Include tahoe capabilities in whereis display. * import: Changed to honor annex.largefiles settings. + * addurl, importfeed: Changed to honor annex.largefiles settings, + when the content of the url is downloaded. (Not when using --fast or + --relaxed.) -- Joey Hess <id@joeyh.name> Mon, 16 Nov 2015 16:49:34 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index e41f9d655..2020ccf3f 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -801,7 +801,10 @@ Here are all the supported configuration settings. annex.largefiles = largerthan=100kb and not (include=*.c or include=*.h) - This setting is used by `git annex add`, `git annex import` and the assistant. + This setting is checked by `git annex add`, `git annex import` and the assistant. + It's also used by `git annex addurl` and `git annex importfeed` when + downloading files. + It can be useful to temporarily override it via -c at the command line. For example: diff --git a/doc/todo/make_addurl_respect_annex.largefiles_option.mdwn b/doc/todo/make_addurl_respect_annex.largefiles_option.mdwn index 340464948..b80349a76 100644 --- a/doc/todo/make_addurl_respect_annex.largefiles_option.mdwn +++ b/doc/todo/make_addurl_respect_annex.largefiles_option.mdwn @@ -2,3 +2,5 @@ ATM git annex addurl ignores annex.largefiles option so to automate annexificat N.B. I do understand that use-case might be somewhat vague, let me know if I should expand reasoning [[!meta author=yoh]] + +> [[done]] --[[Joey]] |