2011-03-05 21:23:55 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Whereis where
|
|
|
|
|
2011-10-05 20:02:51 +00:00
|
|
|
import Common.Annex
|
2011-10-15 20:21:08 +00:00
|
|
|
import Logs.Location
|
2011-03-05 21:23:55 +00:00
|
|
|
import Command
|
2011-07-01 19:24:07 +00:00
|
|
|
import Remote
|
2011-10-15 20:21:08 +00:00
|
|
|
import Logs.Trust
|
2011-03-05 21:23:55 +00:00
|
|
|
|
|
|
|
command :: [Command]
|
2011-10-27 22:56:54 +00:00
|
|
|
command = [Command "whereis" paramPaths defaultChecks seek
|
2011-03-05 21:23:55 +00:00
|
|
|
"lists repositories that have file content"]
|
|
|
|
|
|
|
|
seek :: [CommandSeek]
|
|
|
|
seek = [withFilesInGit start]
|
|
|
|
|
2011-09-15 20:50:49 +00:00
|
|
|
start :: FilePath -> CommandStart
|
2011-03-05 21:23:55 +00:00
|
|
|
start file = isAnnexed file $ \(key, _) -> do
|
|
|
|
showStart "whereis" file
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ perform key
|
2011-03-05 21:23:55 +00:00
|
|
|
|
|
|
|
perform :: Key -> CommandPerform
|
|
|
|
perform key = do
|
2011-09-14 19:33:21 +00:00
|
|
|
(untrustedlocations, safelocations) <- trustPartition UnTrusted =<< keyLocations key
|
2011-09-06 20:59:53 +00:00
|
|
|
let num = length safelocations
|
2011-03-05 21:41:36 +00:00
|
|
|
showNote $ show num ++ " " ++ copiesplural num
|
2011-09-06 20:59:53 +00:00
|
|
|
pp <- prettyPrintUUIDs "whereis" safelocations
|
|
|
|
unless (null safelocations) $
|
|
|
|
showLongNote pp
|
|
|
|
pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
|
|
|
|
unless (null untrustedlocations) $
|
|
|
|
showLongNote $ untrustedheader ++ pp'
|
|
|
|
if null safelocations then stop else next $ return True
|
2011-03-05 21:41:36 +00:00
|
|
|
where
|
|
|
|
copiesplural 1 = "copy"
|
|
|
|
copiesplural _ = "copies"
|
2011-09-06 20:59:53 +00:00
|
|
|
untrustedheader = "The following untrusted locations may also have copies:\n"
|