Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

local: fix "file not found" errors on post transfer Hash calculation

Nick Craig-Wood14cab0fff094
diff --git a/backend/local/local.go b/backend/local/local.go
index 126edd4d0..bcd6d9b68 100644
--- a/backend/local/local.go
+++ b/backend/local/local.go
@@ -768,8 +768,17 @@ func (o *Object) Hash(ctx context.Context, r hash.Type) (string, error) {
oldtime := o.modTime
oldsize := o.size
err := o.lstat()
+ var changed bool
if err != nil {
- return "", errors.Wrap(err, "hash: failed to stat")
+ if os.IsNotExist(errors.Cause(err)) {
+ // If file not found then we assume any accumulated
+ // hashes are OK - this will error on Open
+ changed = true
+ } else {
+ return "", errors.Wrap(err, "hash: failed to stat")
+ }
+ } else {
+ changed = !o.modTime.Equal(oldtime) || oldsize != o.size
}
o.fs.objectHashesMu.Lock()
@@ -777,7 +786,7 @@ func (o *Object) Hash(ctx context.Context, r hash.Type) (string, error) {
hashValue, hashFound := o.hashes[r]
o.fs.objectHashesMu.Unlock()
- if !o.modTime.Equal(oldtime) || oldsize != o.size || hashes == nil || !hashFound {
+ if changed || hashes == nil || !hashFound {
var in io.ReadCloser
if !o.translatedLink {