diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-11-05 18:45:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-11-05 18:46:05 -0400 |
commit | eab4110a9010f1654724e712b8fe2d675132a7ef (patch) | |
tree | fcc1556a4367cb3fb99313261bc3bdfc180e2044 /Command/Import.hs | |
parent | d8a1741254643a7c5b324cabe8c00e36b58434d8 (diff) |
import: Avoid very ugly error messages when the directory files are imported to is not a directort, but perhaps an annexed file.
Diffstat (limited to 'Command/Import.hs')
-rw-r--r-- | Command/Import.hs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Command/Import.hs b/Command/Import.hs index 3ace2d2b0..0dbf2e44a 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -89,7 +89,7 @@ start mode (srcfile, destfile) = warning "Could not verify that the content is still present in the annex; not removing from the import location." stop ) - importfile = do + importfile = checkdestdir $ do ignored <- not <$> Annex.getState Annex.force <&&> checkIgnored destfile if ignored then do @@ -99,14 +99,26 @@ start mode (srcfile, destfile) = existing <- liftIO (catchMaybeIO $ getSymbolicLinkStatus destfile) case existing of Nothing -> importfilechecked - (Just s) + Just s | isDirectory s -> notoverwriting "(is a directory)" + | isSymbolicLink s -> notoverwriting "(is a symlink)" | 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)" ) + checkdestdir cont = do + let destdir = parentDir destfile + existing <- liftIO (catchMaybeIO $ getSymbolicLinkStatus destdir) + case existing of + Nothing -> cont + Just s + | isDirectory s -> cont + | otherwise -> do + warning $ "not importing " ++ destfile ++ " because " ++ destdir ++ " is not a directory" + stop + importfilechecked = do liftIO $ createDirectoryIfMissing True (parentDir destfile) liftIO $ if mode == Duplicate || mode == SkipDuplicates |