SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix: properly handle errors in writeToFile to prevent 0-byte EC shards (#7620)
Chris Lufdb888729b66
diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.goindex 84a9035cac..5ff8bb587c 100644--- a/weed/server/volume_grpc_copy.go+++ b/weed/server/volume_grpc_copy.go@@ -264,7 +264,7 @@ func writeToFile(client volume_server_pb.VolumeServer_CopyFileClient, fileName s}dst, err := os.OpenFile(fileName, flags, 0644)if err != nil {- return modifiedTsNs, nil+ return modifiedTsNs, fmt.Errorf("open file %s: %w", fileName, err)}defer dst.Close()@@ -278,9 +278,11 @@ func writeToFile(client volume_server_pb.VolumeServer_CopyFileClient, fileName smodifiedTsNs = resp.ModifiedTsNs}if receiveErr != nil {- return modifiedTsNs, fmt.Errorf("receiving %s: %v", fileName, receiveErr)+ return modifiedTsNs, fmt.Errorf("receiving %s: %w", fileName, receiveErr)+ }+ if _, writeErr := dst.Write(resp.FileContent); writeErr != nil {+ return modifiedTsNs, fmt.Errorf("write file %s: %w", fileName, writeErr)}- dst.Write(resp.FileContent)progressedBytes += int64(len(resp.FileContent))if progressFn != nil {if !progressFn(progressedBytes) {