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.
This commit is contained in:
Joey Hess 2018-10-04 17:33:25 -04:00
parent ca66e7b66a
commit 451171b7c1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
14 changed files with 77 additions and 26 deletions

View file

@ -233,7 +233,8 @@ addUrlChecked o url file u checkexistssize key =
(exists, samesize, url') <- checkexistssize key
if exists && (samesize || relaxedOption (downloadOptions o))
then do
setUrlPresent u key url'
setUrlPresent key url'
logChange key u InfoPresent
next $ return True
else do
warning $ "while adding a new url to an already annexed file, " ++ if exists
@ -397,7 +398,8 @@ addWorkTree u url file key mtmp = case mtmp of
where
go = do
maybeShowJSON $ JSONChunk [("key", key2file key)]
setUrlPresent u key url
setUrlPresent key url
logChange key u InfoPresent
ifM (addAnnexedFile file key mtmp)
( do
when (isJust mtmp) $

View file

@ -17,7 +17,6 @@ import qualified Command.Fsck
import qualified Annex
import Logs.MetaData
import Logs.Web
import qualified Remote
cmd :: Command
cmd = notDirect $ withGlobalOptions [annexedMatchingOptions] $
@ -78,9 +77,8 @@ perform file oldkey oldbackend newbackend = go =<< genkey (fastMigrate oldbacken
-- If the old key had some associated urls, record them for
-- the new key as well.
urls <- getUrls oldkey
forM_ urls $ \url -> do
r <- Remote.claimingUrl url
setUrlPresent (Remote.uuid r) newkey url
forM_ urls $ \url ->
setUrlPresent newkey url
next $ Command.ReKey.cleanup file oldkey newkey
, error "failed"
)

View file

@ -69,5 +69,5 @@ perform key url = do
perform' :: Key -> URLString -> Annex Bool
perform' key url = do
r <- Remote.claimingUrl url
setUrlPresent (Remote.uuid r) key (setDownloader' url r)
setUrlPresent key (setDownloader' url r)
return True

View file

@ -49,5 +49,5 @@ start (file, url) = flip whenAnnexed file $ \_ key -> do
cleanup :: String -> Key -> CommandCleanup
cleanup url key = do
r <- Remote.claimingUrl url
setUrlMissing (Remote.uuid r) key (setDownloader' url r)
setUrlMissing key (setDownloader' url r)
return True