summaryrefslogtreecommitdiff
path: root/Command/Import.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-29 13:56:41 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-29 13:56:41 -0400
commit4ade15a1fc13771629f8d0f462b8db9f199c169d (patch)
treed8e483e228afd025979b622981eac5c1ba7fd041 /Command/Import.hs
parent2c6138624116e406509ac31cc6fdfdcb0614981c (diff)
import: Don't stop entire import when one file fails due to being gitignored or conflicting with something in the work tree.
Diffstat (limited to 'Command/Import.hs')
-rw-r--r--Command/Import.hs38
1 files changed, 23 insertions, 15 deletions
diff --git a/Command/Import.hs b/Command/Import.hs
index 060be6c65..261bd7b8e 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -79,24 +79,32 @@ start mode (srcfile, destfile) =
liftIO $ removeFile srcfile
next $ return True
importfile = do
- handleexisting =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile)
ignored <- not <$> Annex.getState Annex.force <&&> checkIgnored destfile
if ignored
- then error $ "not importing " ++ destfile ++ " which is .gitignored (use --force to override)"
+ then do
+ warning $ "not importing " ++ destfile ++ " which is .gitignored (use --force to override)"
+ stop
else do
- liftIO $ createDirectoryIfMissing True (parentDir destfile)
- liftIO $ if mode == Duplicate || mode == SkipDuplicates
- then void $ copyFileExternal CopyAllMetaData srcfile destfile
- else moveFile srcfile destfile
- Command.Add.perform destfile
- handleexisting Nothing = noop
- handleexisting (Just s)
- | isDirectory s = notoverwriting "(is a directory)"
- | otherwise = ifM (Annex.getState Annex.force)
- ( liftIO $ nukeFile destfile
- , notoverwriting "(use --force to override, or a duplication option such as --deduplicate to clean up)"
- )
- notoverwriting why = error $ "not overwriting existing " ++ destfile ++ " " ++ why
+ existing <- liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile)
+ case existing of
+ Nothing -> importfilechecked
+ (Just s)
+ | isDirectory s -> notoverwriting "(is a directory)"
+ | otherwise -> ifM (Annex.getState Annex.force)
+ ( do
+ liftIO $ nukeFile destfile
+ importfilechecked
+ , notoverwriting "(use --force to override, or a duplication option such as --deduplicate to clean up)"
+ )
+ importfilechecked = do
+ liftIO $ createDirectoryIfMissing True (parentDir destfile)
+ liftIO $ if mode == Duplicate || mode == SkipDuplicates
+ then void $ copyFileExternal CopyAllMetaData srcfile destfile
+ else moveFile srcfile destfile
+ Command.Add.perform destfile
+ notoverwriting why = do
+ warning $ "not overwriting existing " ++ destfile ++ " " ++ why
+ stop
checkdup dupa notdupa = do
backend <- chooseBackend destfile
let ks = KeySource srcfile srcfile Nothing