summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-17 13:13:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-17 13:13:49 -0400
commit6d4fc0ca7eb220298e42d368ead57622e80929a3 (patch)
tree9b45c0f0a18e54cc999f487de509269c5bab4aa7 /Backend
parent8f6e5da18f80ea5dfc124afed0ff2671a3909d56 (diff)
command output cleanup
Diffstat (limited to 'Backend')
-rw-r--r--Backend/File.hs59
1 files changed, 30 insertions, 29 deletions
diff --git a/Backend/File.hs b/Backend/File.hs
index 591ff3db4..f7796532b 100644
--- a/Backend/File.hs
+++ b/Backend/File.hs
@@ -53,12 +53,13 @@ copyKeyFile key file = do
remotes <- Remotes.withKey key
if (0 == length remotes)
then cantfind
- else return ()
- trycopy remotes remotes
+ else trycopy remotes remotes
where
- trycopy full [] = error $ "unable to get file with key: " ++ (keyFile key) ++ "\n" ++
- "To get that file, need access to one of these remotes: " ++
- (Remotes.list full)
+ trycopy full [] = do
+ showNote $
+ "need access to one of these remotes: " ++
+ (Remotes.list full)
+ return False
trycopy full (r:rs) = do
-- annexLocation needs the git config to have been
-- read for a remote, so do that now,
@@ -67,6 +68,7 @@ copyKeyFile key file = do
case (result) of
Nothing -> trycopy full rs
Just r' -> do
+ showNote $ "copying from " ++ (Git.repoDescribe r ) ++ "..."
result <- liftIO $ (try (copyFromRemote r' key file)::IO (Either SomeException ()))
case (result) of
Left err -> do
@@ -77,17 +79,15 @@ copyKeyFile key file = do
g <- Annex.gitRepo
uuids <- liftIO $ keyLocations g key
ppuuids <- prettyPrintUUIDs uuids
- error $ "no available git remotes have file with key: " ++
- (keyFile key) ++
- if (0 < length uuids)
- then "\nIt has been seen before in these repositories:\n" ++ ppuuids
- else ""
+ showNote $ "No available git remotes have the file."
+ if (0 < length uuids)
+ then showLongNote $ "It has been seen before in these repositories:\n" ++ ppuuids
+ else return ()
+ return False
{- Tries to copy a file from a remote, exception on error. -}
copyFromRemote :: Git.Repo -> Key -> FilePath -> IO ()
copyFromRemote r key file = do
- putStrLn $ "copy from " ++ (Git.repoDescribe r ) ++ " " ++ file
-
if (Git.repoIsLocal r)
then getlocal
else getremote
@@ -116,9 +116,6 @@ checkRemoveKey key = do
then retNotEnoughCopiesKnown remotes numcopies
else findcopies numcopies remotes []
where
- failMsg w = do
- liftIO $ hPutStrLn stderr $ "git-annex: " ++ w
- return False -- failure, not enough copies found
findcopies 0 _ _ = return True -- success, enough copies found
findcopies _ [] bad = notEnoughCopiesSeen bad
findcopies n (r:rs) bad = do
@@ -134,21 +131,25 @@ checkRemoveKey key = do
a <- Annex.new r all
(result, _) <- Annex.run a (Backend.hasKey key)
return result
- notEnoughCopiesSeen bad = failMsg $
- "I failed to find enough other copies of: " ++
- (keyFile key) ++
- (if (0 /= length bad) then listbad bad else "")
- ++ unsafe
- listbad bad = "\nI was unable to access these remotes: " ++
- (Remotes.list bad)
- retNotEnoughCopiesKnown remotes numcopies = failMsg $
+ notEnoughCopiesSeen bad = do
+ showNote "failed to find enough other copies of the file"
+ if (0 /= length bad) then listbad bad else return ()
+ unsafe
+ return False
+ listbad bad =
+ showLongNote $
+ "I was unable to access these remotes: " ++
+ (Remotes.list bad)
+ retNotEnoughCopiesKnown remotes numcopies = do
+ showNote $
"I only know about " ++ (show $ length remotes) ++
" out of " ++ (show numcopies) ++
- " necessary copies of: " ++ (keyFile key) ++
- unsafe
- unsafe = "\n" ++
- " -- According to the " ++ config ++
- " setting, it is not safe to remove it!\n" ++
- " (Use --force to override.)"
+ " necessary copies of the file"
+ unsafe
+ return False
+ unsafe = do
+ showLongNote $ "According to the " ++ config ++
+ " setting, it is not safe to remove it!"
+ showLongNote "(Use --force to override.)"
config = "annex.numcopies"