improve list of remotes in error message
This commit is contained in:
parent
885f7048d5
commit
1448d8b42d
1 changed files with 16 additions and 20 deletions
|
@ -54,13 +54,13 @@ copyKeyFile key file = do
|
||||||
if null remotes
|
if null remotes
|
||||||
then do
|
then do
|
||||||
showNote "not available"
|
showNote "not available"
|
||||||
showLocations key
|
showLocations key []
|
||||||
return False
|
return False
|
||||||
else trycopy remotes remotes
|
else trycopy remotes remotes
|
||||||
where
|
where
|
||||||
trycopy full [] = do
|
trycopy full [] = do
|
||||||
showTriedRemotes full
|
showTriedRemotes full
|
||||||
showLocations key
|
showLocations key []
|
||||||
return False
|
return False
|
||||||
trycopy full (r:rs) = do
|
trycopy full (r:rs) = do
|
||||||
probablythere <- probablyPresent r
|
probablythere <- probablyPresent r
|
||||||
|
@ -95,44 +95,40 @@ checkRemoveKey key numcopiesM = do
|
||||||
(trusted, untrusted) <- Remotes.keyPossibilities key
|
(trusted, untrusted) <- Remotes.keyPossibilities key
|
||||||
numcopies <- getNumCopies numcopiesM
|
numcopies <- getNumCopies numcopiesM
|
||||||
trusteduuids <- mapM getUUID trusted
|
trusteduuids <- mapM getUUID trusted
|
||||||
if numcopies > length untrusted
|
findcopies numcopies trusteduuids untrusted []
|
||||||
then notEnoughCopies numcopies (length untrusted) []
|
|
||||||
else findcopies numcopies trusteduuids untrusted []
|
|
||||||
where
|
where
|
||||||
findcopies need have [] bad
|
findcopies need have [] bad
|
||||||
| length have >= need = return True
|
| length have >= need = return True
|
||||||
| otherwise = notEnoughCopies need (length have) bad
|
| otherwise = notEnoughCopies need have bad
|
||||||
findcopies need have (r:rs) bad
|
findcopies need have (r:rs) bad
|
||||||
| length have >= need = return True
|
| length have >= need = return True
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
u <- getUUID r
|
u <- getUUID r
|
||||||
if not $ elem u have
|
let dup = elem u have
|
||||||
then do
|
haskey <- Remotes.inAnnex r key
|
||||||
haskey <- Remotes.inAnnex r key
|
case (dup, haskey) of
|
||||||
case haskey of
|
(False, Right True) -> findcopies need (u:have) rs bad
|
||||||
Right True -> findcopies need (u:have) rs bad
|
(False, Left _) -> findcopies need have rs (r:bad)
|
||||||
Right False -> findcopies need have rs bad
|
_ -> findcopies need have rs bad
|
||||||
Left _ -> findcopies need have rs (r:bad)
|
notEnoughCopies need have bad = do
|
||||||
else findcopies need have rs bad
|
|
||||||
notEnoughCopies need numhave bad = do
|
|
||||||
unsafe
|
unsafe
|
||||||
showLongNote $
|
showLongNote $
|
||||||
"Could only verify the existence of " ++
|
"Could only verify the existence of " ++
|
||||||
show numhave ++ " out of " ++ show need ++
|
show (length have) ++ " out of " ++ show need ++
|
||||||
" necessary copies"
|
" necessary copies"
|
||||||
showTriedRemotes bad
|
showTriedRemotes bad
|
||||||
showLocations key
|
showLocations key have
|
||||||
hint
|
hint
|
||||||
return False
|
return False
|
||||||
unsafe = showNote "unsafe"
|
unsafe = showNote "unsafe"
|
||||||
hint = showLongNote "(Use --force to override this check, or adjust annex.numcopies.)"
|
hint = showLongNote "(Use --force to override this check, or adjust annex.numcopies.)"
|
||||||
|
|
||||||
showLocations :: Key -> Annex ()
|
showLocations :: Key -> [UUID] -> Annex ()
|
||||||
showLocations key = do
|
showLocations key exclude = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
uuids <- liftIO $ keyLocations g key
|
uuids <- liftIO $ keyLocations g key
|
||||||
let uuidsf = filter (/= u) uuids
|
let uuidsf = filter (\l -> l /= u && (not $ elem l exclude)) uuids
|
||||||
ppuuids <- prettyPrintUUIDs uuidsf
|
ppuuids <- prettyPrintUUIDs uuidsf
|
||||||
if null uuidsf
|
if null uuidsf
|
||||||
then showLongNote $ "No other repository is known to contain the file."
|
then showLongNote $ "No other repository is known to contain the file."
|
||||||
|
|
Loading…
Add table
Reference in a new issue