Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
handle no \n at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Apr 11, 2017
1 parent bc3a0f7 commit c6871c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ func (store *Store) readExistingData(fileDataPath string) error {
topicIDToTopic := make(map[int]*Topic)
for len(d) > 0 {
idx := bytes.IndexByte(d, '\n')
if -1 == idx {
// TODO: this could happen if the last record was only
// partially written. Should I just ignore it?
panic("idx shouldn't be -1")
if -1 != idx {
line := d[:idx]
d = d[idx+1:]
} else {
line = d
d = nil
}
line := d[:idx]
//fmt.Printf("%q len(topics)=%d\n", string(line), len(topics))
d = d[idx+1:]
c := line[0]
// T - topic
// P - post
Expand Down

0 comments on commit c6871c7

Please sign in to comment.