summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2014-12-29 14:22:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2014-12-29 14:22:47 -0400
commitdd7bf0eedebe4f01d702f6450a5c0b5180775c07 (patch)
treee1de44ee666ce9bf0719e68edd47b517560ec418
parent9315d96f700109da18f953534b0b5bab8d1440dd (diff)
fix addurl behavior when location and url logs are inconsistent
The url log could have an url for a key, while the location log thinks it's not present in the web. In this case, addurl --file url would not do anything. Fixed it to re-add the web as a location. I don't know how this situation could arise, but I saw it in the wild in the conference_proceedings repo, affecting key URL-s17806003--http://mirror.linux.org.au/pub/linux.conf.au/2014/Wednesday/53-Building_Effective_Alliances_around_the_Trans-Pacific_Partnershi-c0505b631127ccc67e38e637344d988e Investigating the presence log, it looked like that key was originally listed as present in the web, then in commit 56abf9e9f3e691ed9d83513037d4019313321ca3 someone else's git-annex set it and some other things to not present in the web. It would be interesting to know what that user did, but I doubt I'll be able to find out. All I can tell from this investigation is that the inconsistency was not introduced when originally addurl-ing the url.
-rw-r--r--Command/AddUrl.hs2
-rw-r--r--Logs/Web.hs4
2 files changed, 3 insertions, 3 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 66a5c4e3d..97adc75ee 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -210,7 +210,7 @@ addUrlChecked relaxed url u checkexistssize key
| relaxed = do
setUrlPresent u key url
next $ return True
- | otherwise = ifM (elem url <$> getUrls key)
+ | otherwise = ifM ((elem url <$> getUrls key) <&&> (elem u <$> loggedLocations key))
( next $ return True -- nothing to do
, do
(exists, samesize) <- checkexistssize key
diff --git a/Logs/Web.hs b/Logs/Web.hs
index a728d152b..39f177c3b 100644
--- a/Logs/Web.hs
+++ b/Logs/Web.hs
@@ -54,9 +54,9 @@ getUrlsWithPrefix key prefix = filter (prefix `isPrefixOf`) <$> getUrls key
setUrlPresent :: UUID -> Key -> URLString -> Annex ()
setUrlPresent uuid key url = do
us <- getUrls key
- unless (url `elem` us) $ do
+ unless (url `elem` us) $
addLog (urlLogFile key) =<< logNow InfoPresent url
- logChange key uuid InfoPresent
+ logChange key uuid InfoPresent
setUrlMissing :: UUID -> Key -> URLString -> Annex ()
setUrlMissing uuid key url = do