diff options
| author | chrislu <chris.lu@gmail.com> | 2023-04-17 22:56:21 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2023-04-17 22:56:21 -0700 |
| commit | 0a22eea55df8462d8fdfc206f4995304ddaca5d9 (patch) | |
| tree | 6ddf9797c1e817e62522e69d4f149cae36e3e8ad /weed/storage/erasure_coding/ec_decoder.go | |
| parent | d50d736e68feb8896b7d3776ffe000fe2ebd2e7c (diff) | |
| download | seaweedfs-0a22eea55df8462d8fdfc206f4995304ddaca5d9.tar.xz seaweedfs-0a22eea55df8462d8fdfc206f4995304ddaca5d9.zip | |
collect ec shard from multiple locations
fix https://github.com/seaweedfs/seaweedfs/issues/4365
Diffstat (limited to 'weed/storage/erasure_coding/ec_decoder.go')
| -rw-r--r-- | weed/storage/erasure_coding/ec_decoder.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/weed/storage/erasure_coding/ec_decoder.go b/weed/storage/erasure_coding/ec_decoder.go index a545d9975..9a415fc78 100644 --- a/weed/storage/erasure_coding/ec_decoder.go +++ b/weed/storage/erasure_coding/ec_decoder.go @@ -151,7 +151,7 @@ func iterateEcjFile(baseFileName string, processNeedleFn func(key types.NeedleId } // WriteDatFile generates .dat from from .ec00 ~ .ec09 files -func WriteDatFile(baseFileName string, datFileSize int64) error { +func WriteDatFile(baseFileName string, datFileSize int64, shardFileNames []string) error { datFile, openErr := os.OpenFile(baseFileName+".dat", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if openErr != nil { @@ -161,13 +161,19 @@ func WriteDatFile(baseFileName string, datFileSize int64) error { inputFiles := make([]*os.File, DataShardsCount) + defer func() { + for shardId := 0; shardId < DataShardsCount; shardId++ { + if inputFiles[shardId] != nil { + inputFiles[shardId].Close() + } + } + }() + for shardId := 0; shardId < DataShardsCount; shardId++ { - shardFileName := baseFileName + ToExt(shardId) - inputFiles[shardId], openErr = os.OpenFile(shardFileName, os.O_RDONLY, 0) + inputFiles[shardId], openErr = os.OpenFile(shardFileNames[shardId], os.O_RDONLY, 0) if openErr != nil { return openErr } - defer inputFiles[shardId].Close() } for datFileSize >= DataShardsCount*ErasureCodingLargeBlockSize { |
