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() {
104103func (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
111110func (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