MCPcopy Create free account
hub / github.com/alibaba/open-code-review / walkSessionFile

Function walkSessionFile

internal/session/list.go:185–208  ·  view source on GitHub ↗
(path string, apply func(summaryRecord))

Source from the content-addressed store, hash-verified

183}
184
185func walkSessionFile(path string, apply func(summaryRecord)) error {
186 f, err := os.Open(path)
187 if err != nil {
188 return fmt.Errorf("open session %q: %w", path, err)
189 }
190 defer f.Close()
191
192 reader := bufio.NewReader(f)
193 for {
194 line, readErr := reader.ReadBytes('\n')
195 if len(line) > 0 {
196 var rec summaryRecord
197 if err := json.Unmarshal(line, &rec); err == nil {
198 apply(rec)
199 }
200 }
201 if readErr == io.EOF {
202 return nil
203 }
204 if readErr != nil {
205 return fmt.Errorf("read session %q: %w", path, readErr)
206 }
207 }
208}
209
210func applyRecordToSummary(s *Summary, rec summaryRecord) {
211 ts := parseRecordTime(rec.Timestamp)

Callers 3

LoadCommentsFunction · 0.85
LoadDetailFunction · 0.85
loadSummaryFromFileFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected