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
filer.sync: fix replicating partially updated file
chrislu9405eaefdbd8
diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.goindex be18d45ac0..d18d06f2cb 100644--- a/weed/filer/filechunks.go+++ b/weed/filer/filechunks.go@@ -101,6 +101,21 @@ func DoMinusChunks(as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk) {return}+func DoMinusChunksBySourceFileId(as, bs []*filer_pb.FileChunk) (delta []*filer_pb.FileChunk) {++ fileIds := make(map[string]bool)+ for _, interval := range bs {+ fileIds[interval.GetFileIdString()] = true+ }+ for _, chunk := range as {+ if _, found := fileIds[chunk.GetSourceFileId()]; !found {+ delta = append(delta, chunk)+ }+ }++ return+}+type ChunkView struct {FileId stringOffset int64diff --git a/weed/replication/sink/filersink/filer_sink.go b/weed/replication/sink/filersink/filer_sink.goindex c48ab2368a..345c7f13b0 100644--- a/weed/replication/sink/filersink/filer_sink.go+++ b/weed/replication/sink/filersink/filer_sink.go@@ -199,7 +199,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent// delete the chunks that are deleted from the sourceif deleteIncludeChunks {// remove the deleted chunks. Actual data deletion happens in filer UpdateEntry FindUnusedFileChunks- existingEntry.Chunks = filer.DoMinusChunks(existingEntry.Chunks, deletedChunks)+ existingEntry.Chunks = filer.DoMinusChunksBySourceFileId(existingEntry.Chunks, deletedChunks)}// replicate the chunks that are new in the source