From 13fc6a9b6ad4f0ee0a783c91825ab7ad35dd2b64 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 9 Jun 2022 14:24:56 -0400 Subject: [PATCH] fix to use 1 chunk for empty file Fix retrival of an empty file that is stored in a special remote with chunking enabled. The speculative chunk stuff caused a reversion by adding an empty list for the empty file. Which is just wrong; the empty file is still stored on the remote, and should be retrieved like any other file. It uses 1 chunk, so `max 1` is the simple fix. Sponsored-by: Noam Kremen on Patreon --- CHANGELOG | 3 +++ Remote/Helper/Chunked.hs | 2 +- ...n_file_size_0_from_external_spec_remote.mdwn | 2 ++ ..._2_1d78459554bc12d0423a317bd9f466d1._comment | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 doc/bugs/error_out_on_file_size_0_from_external_spec_remote/comment_2_1d78459554bc12d0423a317bd9f466d1._comment diff --git a/CHANGELOG b/CHANGELOG index ae14d55acd..24b3c6cb5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,9 @@ git-annex (10.20220526) UNRELEASED; urgency=medium The location value no longer needs to match the url of an existing git remote, and locations not using ssh:// will work now, including both paths and host:/path + * Fix retrival of an empty file that is stored in a special remote with + chunking enabled. + (Fixes a reversion in 8.20201103) -- Joey Hess Wed, 01 Jun 2022 13:23:05 -0400 diff --git a/Remote/Helper/Chunked.hs b/Remote/Helper/Chunked.hs index a8d928c597..72e33fe77e 100644 --- a/Remote/Helper/Chunked.hs +++ b/Remote/Helper/Chunked.hs @@ -554,7 +554,7 @@ chunkKeys' onlychunks u chunkconfig k = do Nothing -> l Just keysz -> let (d, m) = keysz `divMod` fromIntegral chunksz - chunkcount = d + if m == 0 then 0 else 1 + chunkcount = max 1 (d + if m == 0 then 0 else 1) v = (FixedSizeChunks chunksz, chunkcount) in if v `elem` recorded then l diff --git a/doc/bugs/error_out_on_file_size_0_from_external_spec_remote.mdwn b/doc/bugs/error_out_on_file_size_0_from_external_spec_remote.mdwn index b2358f32a3..a2ad892628 100644 --- a/doc/bugs/error_out_on_file_size_0_from_external_spec_remote.mdwn +++ b/doc/bugs/error_out_on_file_size_0_from_external_spec_remote.mdwn @@ -86,3 +86,5 @@ so I do not think it is an issue of the remote (which might also have some size tried both 8.20211123 and 10.20220504 from debian + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/error_out_on_file_size_0_from_external_spec_remote/comment_2_1d78459554bc12d0423a317bd9f466d1._comment b/doc/bugs/error_out_on_file_size_0_from_external_spec_remote/comment_2_1d78459554bc12d0423a317bd9f466d1._comment new file mode 100644 index 0000000000..a37c6f1d06 --- /dev/null +++ b/doc/bugs/error_out_on_file_size_0_from_external_spec_remote/comment_2_1d78459554bc12d0423a317bd9f466d1._comment @@ -0,0 +1,17 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 2""" + date="2022-06-09T18:05:15Z" + content=""" +This was broken by [[!commit dad4be97c2057db1ef3a13bb983d1701a90c9069]]. + +For a key of size zero, `addspeculative` adds on a `[]` to the list of chunk +key. But that causes retrieveChunks to think that it's already retrieved +all the chunks, so it avoids doing any retrieval, so the file is not +written. It needs to retrieve the empty key even though it's empty, +so it can decrypt it when it's encrypted; git-annex does not special case +empty file retrieval. + +Odd that testremote did not detect this. It does test with empty keys, and +with chunking. +"""]]