summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2018-10-04 17:33:25 -0400
committerJoey Hess <joeyh@joeyh.name>2018-10-04 17:35:49 -0400
commit451171b7c1eaccfd0f39d4ec1d64c6964613f55a (patch)
treedaea8f6a7fb9665b8b75e848e12e34efe3dca88d /Logs
parentca66e7b66aec822f2b8ba8c97de922f71f383fd8 (diff)
clean up url removal presence update
* rmurl: Fix a case where removing the last url left git-annex thinking content was still present in the web special remote. * SETURLPRESENT, SETURIPRESENT, SETURLMISSING, and SETURIMISSING used to update the presence information of the external special remote that called them; this was not documented behavior and is no longer done. Done by making setUrlPresent and setUrlMissing only update presence info for the web, and only when the url is a web url. See the comment for reasoning about why that's the right thing to do. In AddUrl, had to make it update location tracking, to handle the non-web-url case. This commit was sponsored by Ewen McNeill on Patreon.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Web.hs26
1 files changed, 19 insertions, 7 deletions
diff --git a/Logs/Web.hs b/Logs/Web.hs
index bfe971e8aa..1d69dc8bde 100644
--- a/Logs/Web.hs
+++ b/Logs/Web.hs
@@ -56,20 +56,32 @@ getUrlsWithPrefix key prefix = filter (prefix `isPrefixOf`)
. map (fst . getDownloader)
<$> getUrls key
-setUrlPresent :: UUID -> Key -> URLString -> Annex ()
-setUrlPresent uuid key url = do
+setUrlPresent :: Key -> URLString -> Annex ()
+setUrlPresent key url = do
us <- getUrls key
unless (url `elem` us) $ do
config <- Annex.getGitConfig
addLog (urlLogFile config key) =<< logNow InfoPresent url
- logChange key uuid InfoPresent
+ -- If the url does not have an OtherDownloader, it must be present
+ -- in the web.
+ case snd (getDownloader url) of
+ OtherDownloader -> return ()
+ _ -> logChange key webUUID InfoPresent
-setUrlMissing :: UUID -> Key -> URLString -> Annex ()
-setUrlMissing uuid key url = do
+setUrlMissing :: Key -> URLString -> Annex ()
+setUrlMissing key url = do
config <- Annex.getGitConfig
addLog (urlLogFile config key) =<< logNow InfoMissing url
- whenM (null <$> getUrls key) $
- logChange key uuid InfoMissing
+ -- If the url was a web url (not OtherDownloader) and none of
+ -- the remaining urls for the key are web urls, the key must not
+ -- be present in the web.
+ when (isweb url) $
+ whenM (null . filter isweb <$> getUrls key) $
+ logChange key webUUID InfoMissing
+ where
+ isweb u = case snd (getDownloader u) of
+ OtherDownloader -> False
+ _ -> True
{- Finds all known urls. -}
knownUrls :: Annex [(Key, URLString)]