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.
This commit is contained in:
Nick Craig-Wood 2023-11-18 15:50:04 +00:00
parent ddaf01ece9
commit 168d577297

View File

@ -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