aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/erasure_coding/ec_volume.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/storage/erasure_coding/ec_volume.go')
-rw-r--r--weed/storage/erasure_coding/ec_volume.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/weed/storage/erasure_coding/ec_volume.go b/weed/storage/erasure_coding/ec_volume.go
index 8bd7237f5..44d8ca80f 100644
--- a/weed/storage/erasure_coding/ec_volume.go
+++ b/weed/storage/erasure_coding/ec_volume.go
@@ -61,7 +61,7 @@ func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool {
return true
}
-func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) bool {
+func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, deleted bool) {
foundPosition := -1
for i, s := range ev.Shards {
if s.ShardId == shardId {
@@ -69,11 +69,13 @@ func (ev *EcVolume) DeleteEcVolumeShard(shardId ShardId) bool {
}
}
if foundPosition < 0 {
- return false
+ return nil, false
}
+ ecVolumeShard = ev.Shards[foundPosition]
+
ev.Shards = append(ev.Shards[:foundPosition], ev.Shards[foundPosition+1:]...)
- return true
+ return ecVolumeShard, true
}
func (ev *EcVolume) FindEcVolumeShard(shardId ShardId) (ecVolumeShard *EcVolumeShard, found bool) {
@@ -99,11 +101,16 @@ func (ev *EcVolume) Destroy() {
ev.Close()
- baseFileName := EcShardFileName(ev.Collection, ev.dir, int(ev.VolumeId))
for _, s := range ev.Shards {
s.Destroy()
}
- os.Remove(baseFileName + ".ecx")
+ os.Remove(ev.FileName() + ".ecx")
+}
+
+func (ev *EcVolume) FileName() string {
+
+ return EcShardFileName(ev.Collection, ev.dir, int(ev.VolumeId))
+
}
func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.VolumeEcShardInformationMessage) {