From 8e7728b312704f6f4cb84d81302c1518f0e85948 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Dec 2015 14:48:42 -0400 Subject: import: Changed to honor annex.largefiles settings. --- Command/Add.hs | 6 +++++- Command/Import.hs | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'Command') diff --git a/Command/Add.hs b/Command/Add.hs index fd92f04ef..4ae97b6e3 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -73,8 +73,12 @@ seek o = allowConcurrentOutput $ do startSmall :: FilePath -> CommandStart startSmall file = do showStart "add" file + next $ performSmall file + +performSmall :: FilePath -> CommandPerform +performSmall file = do showNote "non-large file; adding content to git repository" - next $ performAdd file + performAdd file performAdd :: FilePath -> CommandPerform performAdd file = do diff --git a/Command/Import.hs b/Command/Import.hs index 0dbf2e44a..3887ea57b 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -19,6 +19,8 @@ import Types.KeySource import Types.Key import Annex.CheckIgnore import Annex.NumCopies +import Types.FileMatcher +import Annex.FileMatcher cmd :: Command cmd = withGlobalOptions (jobsOption : fileMatchingOptions) $ notBareRepo $ @@ -64,10 +66,11 @@ seek o = allowConcurrentOutput $ do inrepops <- liftIO $ filter (dirContains repopath) <$> mapM absPath (importFiles o) unless (null inrepops) $ do error $ "cannot import files from inside the working tree (use git annex add instead): " ++ unwords inrepops - withPathContents (start (duplicateMode o)) (importFiles o) + largematcher <- largeFilesMatcher + withPathContents (start largematcher (duplicateMode o)) (importFiles o) -start :: DuplicateMode -> (FilePath, FilePath) -> CommandStart -start mode (srcfile, destfile) = +start :: FileMatcher Annex -> DuplicateMode -> (FilePath, FilePath) -> CommandStart +start largematcher mode (srcfile, destfile) = ifM (liftIO $ isRegularFile <$> getSymbolicLinkStatus srcfile) ( do ma <- pickaction @@ -124,7 +127,10 @@ start mode (srcfile, destfile) = liftIO $ if mode == Duplicate || mode == SkipDuplicates then void $ copyFileExternal CopyAllMetaData srcfile destfile else moveFile srcfile destfile - Command.Add.perform destfile + ifM (checkFileMatcher largematcher destfile) + ( Command.Add.perform destfile + , Command.Add.performSmall destfile + ) notoverwriting why = do warning $ "not overwriting existing " ++ destfile ++ " " ++ why stop -- cgit v1.2.3