improve addurl --file behavior in a confusing corner case involving a ftp url

This commit is contained in:
Joey Hess 2014-04-02 15:22:39 -04:00
parent f02cf1ab5a
commit 1c965f5918
Failed to extract signature
2 changed files with 15 additions and 11 deletions

View file

@ -134,17 +134,20 @@ perform relaxed url file = ifAnnexed file addurl geturl
| relaxed = do | relaxed = do
setUrlPresent key url setUrlPresent key url
next $ return True next $ return True
| otherwise = do | otherwise = ifM (elem url <$> getUrls key)
(exists, samesize) <- Url.withUrlOptions $ Url.check url (keySize key) ( stop
if exists && samesize , do
then do (exists, samesize) <- Url.withUrlOptions $ Url.check url (keySize key)
setUrlPresent key url if exists && samesize
next $ return True then do
else do setUrlPresent key url
warning $ if exists next $ return True
then "url does not have expected file size (use --relaxed to bypass this check) " ++ url else do
else "failed to verify url exists: " ++ url warning $ "while adding a new url to an already annexed file, " ++ if exists
stop then "url does not have expected file size (use --relaxed to bypass this check) " ++ url
else "failed to verify url exists: " ++ url
stop
)
addUrlFile :: Bool -> URLString -> FilePath -> Annex Bool addUrlFile :: Bool -> URLString -> FilePath -> Annex Bool
addUrlFile relaxed url file = do addUrlFile relaxed url file = do

View file

@ -64,3 +64,4 @@ I am using current git-annex binary linux version on Fedora 19.
supported repository version: 5 supported repository version: 5
upgrade supported from repository versions: 0 1 2 4 upgrade supported from repository versions: 0 1 2 4
> [[done]] --[[Joey]]