sync --content: Fix bug that caused files to be uploaded to eg, more archive remotes than wanted copies, only to later be dropped to satisfy the preferred content settings.

This commit is contained in:
Joey Hess 2015-07-20 14:24:13 -04:00
parent 8af26ae2e0
commit 3c134ee21a
4 changed files with 50 additions and 8 deletions

View file

@ -414,7 +414,7 @@ syncFile ebloom rs af k = do
let (have, lack) = partition (\r -> Remote.uuid r `elem` locs) rs
got <- anyM id =<< handleget have
putrs <- catMaybes . snd . unzip <$> (sequence =<< handleput lack)
putrs <- handleput lack
u <- getUUID
let locs' = concat [[u | got], putrs, locs]
@ -455,12 +455,14 @@ syncFile ebloom rs af k = do
wantput r
| Remote.readonly r || remoteAnnexReadOnly (Remote.gitconfig r) = return False
| otherwise = wantSend True (Just k) af (Remote.uuid r)
handleput lack = ifM (inAnnex k)
( map put <$> filterM wantput lack
handleput lack = catMaybes <$> ifM (inAnnex k)
( forM lack $ \r ->
ifM (wantput r <&&> put r)
( return (Just (Remote.uuid r))
, return Nothing
)
, return []
)
put dest = do
ok <- includeCommandAction $ do
showStart' "copy" k af
Command.Move.toStart' dest False af k
return (ok, if ok then Just (Remote.uuid dest) else Nothing)
put dest = includeCommandAction $ do
showStart' "copy" k af
Command.Move.toStart' dest False af k

3
debian/changelog vendored
View file

@ -17,6 +17,9 @@ git-annex (5.20150714) UNRELEASED; urgency=medium
* version --raw now works when run outside a git repository.
* assistant --startdelay now works when run outside a git repository.
* dead now accepts multiple --key options.
* sync --content: Fix bug that caused files to be uploaded to eg,
more archive remotes than wanted copies, only to later be dropped
to satisfy the preferred content settings.
-- Joey Hess <id@joeyh.name> Fri, 10 Jul 2015 16:36:42 -0400

View file

@ -31,3 +31,5 @@ drop hubic3 Avatars/archer.jpg ok
# End of transcript or log.
"""]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,35 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2015-07-20T18:07:04Z"
content="""
A good bug report that I didn't get to for far too long..
I reproduced this fairly easily; both remotes set to be
in the archive group and both set to use the "standard" preferred content
expression.
joey@darkstar:~/tmp/bench/local>git annex sync --content
commit ok
copy file copy file (to hubic3...)
ok
copy file copy file (to hubic2...)
ok
drop hubic3 file ok
It wants to drop the file from hubic3 once it's present on hubic2,
since archive remotes only want files not on other archive remotes.
So, why does it send the file to hubic2, given that it's already in hubic3?
If I manually copy the file to one of the remotes, sync --content won't
send it to the other. So, I suspect it's getting a list of remotes that
want the file first, and then copying the file to all of them.
Aha, indeed:
map put <$> filterM wantput lack
Fixed by making it check if each remote wants the file inside the loop,
rather than checking when getting the list of remotes to loop over.
"""]]