Skip to content

Commit 8341df4

Browse files
committed
修复:自动清理分片数据边界问题
1 parent cbd0f3d commit 8341df4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

reader.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"io/ioutil"
109
"os"
1110
"path"
1211
"path/filepath"
@@ -104,13 +103,13 @@ func (r *reader) close() {
104103
func (r *reader) sync() {
105104
name := path.Join(Config.Path, Config.CheckpointFile)
106105
data, _ := json.Marshal(&r.checkpoint)
107-
_ = ioutil.WriteFile(name, data, Config.FilePerm)
106+
_ = os.WriteFile(name, data, Config.FilePerm)
108107
}
109108

110109
// restore index and offset
111110
func (r *reader) restore() (err error) {
112111
name := path.Join(Config.Path, Config.CheckpointFile)
113-
data, _ := ioutil.ReadFile(name)
112+
data, _ := os.ReadFile(name)
114113
_ = json.Unmarshal(data, &r.checkpoint)
115114
r.index, r.offset = r.checkpoint.Index, r.checkpoint.Offset
116115

@@ -136,7 +135,7 @@ func (r *reader) next() (string, error) {
136135

137136
for _, file := range files {
138137
index := r.getIndex(file)
139-
if index < r.checkpoint.Index {
138+
if index <= r.checkpoint.Index {
140139
_ = os.Remove(file) // remove expired segment
141140
}
142141

0 commit comments

Comments
 (0)