import: Avoid very ugly error messages when the directory files are imported to is not a directort, but perhaps an annexed file.

This commit is contained in:
Joey Hess 2015-11-05 18:45:52 -04:00
parent 5db7d435e7
commit 7dc90f2225
Failed to extract signature
2 changed files with 16 additions and 2 deletions

View file

@ -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

2
debian/changelog vendored
View file

@ -4,6 +4,8 @@ git-annex (5.20151102.2) UNRELEASED; urgency=medium
This allows nicely displayed messages when using the -J flag.
* Additional commands now suppport the -J flag:
fsck, drop, add, addurl, import
* import: Avoid very ugly error messages when the directory files
are imported to is not a directort, but perhaps an annexed file.
-- Joey Hess <id@joeyh.name> Wed, 04 Nov 2015 12:50:20 -0400