From 168d577297e4e84a589ada173425bce7cca8a9ac Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 18 Nov 2023 15:50:04 +0000 Subject: [PATCH] vfs: error out early if can't upload 0 length file Before this change if a backend can't upload 0 length files and `--vfs-cache-mode writes` was in use then the writeback logic would try to upload the 0 length file forever. This change causes it to exit on the first failure to upload. --- vfs/vfscache/item.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index 566e29e32..06a7454a5 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -593,6 +593,10 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) { o, err := operations.Copy(ctx, item.c.fremote, o, name, cacheObj) item.mu.Lock() if err != nil { + if errors.Is(err, fs.ErrorCantUploadEmptyFiles) { + fs.Errorf(name, "Writeback failed: %v", err) + return nil + } return fmt.Errorf("vfs cache: failed to transfer file from cache to remote: %w", err) } item.o = o