summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-06 16:59:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-06 16:59:53 -0400
commit6f98fd53914b2490e866a2613e86b93f689034bf (patch)
treea8b83ec14eaade973485944003506c95abf6d415 /Command
parentb7bcd942c57631f50d686cb8d45a83eaf377c33a (diff)
whereis: Show untrusted locations separately and do not include in location count.
Diffstat (limited to 'Command')
-rw-r--r--Command/Whereis.hs27
1 files changed, 18 insertions, 9 deletions
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index f80c823b7..d5c090e49 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -7,11 +7,15 @@
module Command.Whereis where
+import Control.Monad
+import Data.List
+
import LocationLog
import Command
import Messages
import Remote
import Types
+import Trust
command :: [Command]
command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
@@ -27,16 +31,21 @@ start file = isAnnexed file $ \(key, _) -> do
perform :: Key -> CommandPerform
perform key = do
- uuids <- keyLocations key
- let num = length uuids
+ locations <- keyLocations key
+ untrusted <- trustGet UnTrusted
+ let untrustedlocations = intersect untrusted locations
+ let safelocations = filter (`notElem` untrusted) locations
+ let num = length safelocations
showNote $ show num ++ " " ++ copiesplural num
- if null uuids
- then stop
- else do
- pp <- prettyPrintUUIDs "whereis" uuids
- showLongNote pp
- showOutput
- next $ return True
+ pp <- prettyPrintUUIDs "whereis" safelocations
+ unless (null safelocations) $
+ showLongNote pp
+ pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
+ unless (null untrustedlocations) $
+ showLongNote $ untrustedheader ++ pp'
+ unless (null locations) showOutput
+ if null safelocations then stop else next $ return True
where
copiesplural 1 = "copy"
copiesplural _ = "copies"
+ untrustedheader = "The following untrusted locations may also have copies:\n"