Commit 584eee8
committed
fix(hasher): prevent double-download when syncing with auto_size
When syncing from hasher with auto_size larger than file size, files were
downloaded twice: once by fs.Fingerprint() calling Hash() which triggered
updateHashes(), and again for the actual transfer.
Root cause: checkPartial() calls Fingerprint(ctx, src, fast=true) for
generating stable partial upload suffixes. Fingerprint checks SlowHash
before calling Hash(), but hasher didn't set SlowHash even when computing
hashes requires downloading the entire file.
Fix:
- Set SlowHash=true when passHashes is empty (no fast pass-through hashes
from base). Must be set AFTER Mask() to avoid being ANDed to false.
- Add singleflight to deduplicate concurrent updateHashes() calls for the
same file, preventing redundant downloads from parallel Hash() requests.
When passHashes is non-empty (e.g., S3 with MD5), SlowHash remains false
and Fingerprint uses the fast pass-through hash. When passHashes is empty
(e.g., crypt/SFTP base), Fingerprint skips hashing entirely. Explicit
rclone hashsum commands still work as they call Hash() directly.
Signed-off-by: Anagh Kumar Baranwal <[email protected]>1 parent af0d488 commit 584eee8
3 files changed
+26
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
183 | 186 | | |
184 | 187 | | |
185 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
186 | 194 | | |
187 | 195 | | |
188 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
62 | 76 | | |
63 | 77 | | |
64 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| |||
0 commit comments