import: Avoid checksumming file twice when run in the default or --duplicate mode.
--deduplicate, --skip-duplicates, and --clean-duplicates still checksum the file twice, the first time to determine if it's a duplicate. This cannot be easily merged with the checksumming done to add the file, since the file needs to be locked down before that second checksum is taken.
This commit is contained in:
parent
102458e8f3
commit
27ad41b355
2 changed files with 17 additions and 20 deletions
|
@ -67,14 +67,8 @@ start :: DuplicateMode -> (FilePath, FilePath) -> CommandStart
|
|||
start mode (srcfile, destfile) =
|
||||
ifM (liftIO $ isRegularFile <$> getSymbolicLinkStatus srcfile)
|
||||
( do
|
||||
isdup <- do
|
||||
backend <- chooseBackend destfile
|
||||
let ks = KeySource srcfile srcfile Nothing
|
||||
v <- genKey ks backend
|
||||
case v of
|
||||
Just (k, _) -> not . null <$> keyLocations k
|
||||
_ -> return False
|
||||
case pickaction isdup of
|
||||
ma <- pickaction
|
||||
case ma of
|
||||
Nothing -> stop
|
||||
Just a -> do
|
||||
showStart "import" destfile
|
||||
|
@ -101,15 +95,16 @@ start mode (srcfile, destfile) =
|
|||
, notoverwriting "(use --force to override)"
|
||||
)
|
||||
notoverwriting why = error $ "not overwriting existing " ++ destfile ++ " " ++ why
|
||||
pickaction isdup = case mode of
|
||||
DeDuplicate
|
||||
| isdup -> Just deletedup
|
||||
| otherwise -> Just importfile
|
||||
CleanDuplicates
|
||||
| isdup -> Just deletedup
|
||||
| otherwise -> Nothing
|
||||
SkipDuplicates
|
||||
| isdup -> Nothing
|
||||
| otherwise -> Just importfile
|
||||
_ -> Just importfile
|
||||
|
||||
checkdup dupa notdupa = do
|
||||
backend <- chooseBackend destfile
|
||||
let ks = KeySource srcfile srcfile Nothing
|
||||
v <- genKey ks backend
|
||||
isdup <- case v of
|
||||
Just (k, _) -> not . null <$> keyLocations k
|
||||
_ -> return False
|
||||
return $ if isdup then dupa else notdupa
|
||||
pickaction = case mode of
|
||||
DeDuplicate -> checkdup (Just deletedup) (Just importfile)
|
||||
CleanDuplicates -> checkdup (Just deletedup) Nothing
|
||||
SkipDuplicates -> checkdup Nothing (Just importfile)
|
||||
_ -> return (Just importfile)
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -10,6 +10,8 @@ git-annex (5.20150206) UNRELEASED; urgency=medium
|
|||
--smallerthan, --largerthan
|
||||
* The file matching options are now only accepted by commands that
|
||||
can actually use them, instead of by all commands.
|
||||
* import: Avoid checksumming file twice when run in the default
|
||||
or --duplicate mode.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400
|
||||
|
||||
|
|
Loading…
Reference in a new issue