resume properly when copying a file to/from a local git remote is interrupted

Probably this fixes a reversion, but I don't know what version broke it.

This does use withOtherTmp for a temp file that could be quite large.
Though albeit a reflink copy that will not actually take up any space
as long as the file it was copied from still exists. So if the copy cow
succeeds but git-annex is interrupted just before that temp file gets
renamed into the usual .git/annex/tmp/ location, there is a risk that
the other temp directory ends up cluttered with a larger temp file than
later. It will eventually be cleaned up, and the changes of this being
a problem are small, so this seems like an acceptable thing to do.

Sponsored-by: Shae Erisson on Patreon
This commit is contained in:
Joey Hess 2021-09-21 17:32:10 -04:00
parent c9dd63d67d
commit 63d508e885
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 48 additions and 10 deletions

View file

@ -0,0 +1,21 @@
A copy --to a local git remote that gets interrupted and is run again does
not resume where it left off, but copies all the data again.
This does not affect git remotes accessed over ssh.
It's kind of hard to notice this, because normally a resume, has to read
the src file and dest file, in order for incremental verification to
get started. But it is somewhat slower to do that than it is to re-write
the dest file from the start. And when annex.verify = false, it's a lot
slower.
Looks like it's due to copyCoW unlinking the dest file. Since the first
file copy trues copyCoW to probe if that's supported, that happens.
And when resuming an interrupted copy, that probe will generally happen
with the file it was interrupted on.
So, the solution seems like it would be to copyCoW to some other temp file,
and if it succeeds, rename it to the dest.
--[[Joey]]
> [[fixed|done]] --[[Joey]]