summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-31 15:36:02 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-31 15:36:02 -0400
commitbbdd35fffadc8c441278a229c5819b619471b46f (patch)
treeaedf0710eb311f51f7125cc47fd47c2bf088572d
parente312ef88c62270def28e815e7cec1f63268a358b (diff)
import: --deduplicate and --cleanduplicates now output the keys corresponding to duplicated files they process.
-rw-r--r--Command/Import.hs15
-rw-r--r--debian/changelog2
-rw-r--r--doc/todo/Output_key_with_import__47__deduplicate.mdwn2
3 files changed, 13 insertions, 6 deletions
diff --git a/Command/Import.hs b/Command/Import.hs
index 025563b49..2da26a96b 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -15,6 +15,7 @@ import Utility.CopyFile
import Backend
import Remote
import Types.KeySource
+import Types.Key
cmd :: [Command]
cmd = [withOptions opts $ notBareRepo $ command "import" paramPaths seek
@@ -72,8 +73,8 @@ start mode (srcfile, destfile) =
, stop
)
where
- deletedup = do
- showNote "duplicate"
+ deletedup k = do
+ showNote $ "duplicate of " ++ key2file k
liftIO $ removeFile srcfile
next $ return True
importfile = do
@@ -95,10 +96,12 @@ start mode (srcfile, destfile) =
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
+ case v of
+ Just (k, _) -> ifM (not . null <$> keyLocations k)
+ ( return (maybe Nothing (\a -> Just (a k)) dupa)
+ , return notdupa
+ )
+ _ -> return notdupa
pickaction = case mode of
DeDuplicate -> checkdup (Just deletedup) (Just importfile)
CleanDuplicates -> checkdup (Just deletedup) Nothing
diff --git a/debian/changelog b/debian/changelog
index da1096e40..ae78a676b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,8 @@ git-annex (5.20150328) UNRELEASED; urgency=medium
filename with filenames that the special remote suggests. Also,
don't allow adding the url if the special remote says it contains
multiple files.
+ * import: --deduplicate and --cleanduplicates now output the keys
+ corresponding to duplicated files they process.
-- Joey Hess <id@joeyh.name> Fri, 27 Mar 2015 16:04:43 -0400
diff --git a/doc/todo/Output_key_with_import__47__deduplicate.mdwn b/doc/todo/Output_key_with_import__47__deduplicate.mdwn
index 807d59dfd..81bb653fc 100644
--- a/doc/todo/Output_key_with_import__47__deduplicate.mdwn
+++ b/doc/todo/Output_key_with_import__47__deduplicate.mdwn
@@ -18,3 +18,5 @@ Then you could use
to find out where it is already.
Not sure if that is the nicest layout.. (or what it might break).
+
+> [[done]] --[[Joey]]