Skip to content

Commit

Permalink
Simplified the original list structure, removed a large amount of red…
Browse files Browse the repository at this point in the history
…undant code, and fixed bugs related to file counting.
  • Loading branch information
hwy1314 committed Oct 11, 2023
1 parent fb2176b commit a1fa728
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 374 deletions.
7 changes: 3 additions & 4 deletions internal/aof/aof.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ReadCompleteLine(reader *bufio.Reader) ([]byte, error) {
return line, err
}

func (ld *Loader) LoadSingleAppendOnlyFile(LastFile bool, AOFTimeStamp int64) int {
func (ld *Loader) LoadSingleAppendOnlyFile(AOFTimeStamp int64) int {
ret := AOFOK
AOFFilepath := ld.filPath
fp, err := os.Open(AOFFilepath)
Expand Down Expand Up @@ -103,9 +103,9 @@ func (ld *Loader) LoadSingleAppendOnlyFile(LastFile bool, AOFTimeStamp int64) in
log.Panicf("Invalid timestamp annotation")
}

if ts > AOFTimeStamp && LastFile {
if ts > AOFTimeStamp {
ret = AOFTruncated
log.Infof("AOFTruncated%s", line)
log.Infof("AOFTruncated %s", line)
return ret
}
}
Expand All @@ -125,7 +125,6 @@ func (ld *Loader) LoadSingleAppendOnlyFile(LastFile bool, AOFTimeStamp int64) in
var argv []string

for j := 0; j < int(argc); j++ {
//line, err := reader.ReadString('\n')
line, err := ReadCompleteLine(reader)
if err != nil || line[0] != '$' {
log.Infof("Bad File format reading the append only File %v:make a backup of your AOF File, then use ./redis-check-AOF --fix <FileName.manifest>", AOFFilepath)
Expand Down
10 changes: 5 additions & 5 deletions internal/reader/aof_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ func (r *aofReader) StartRead() chan *entry.Entry {
}
log.Infof("the file stat:%v", fi)
aofLoader := aof.NewLoader(r.path, r.ch)
ret := aofLoader.LoadSingleAppendOnlyFile(true, r.stat.AOFTimestamp)
ret := aofLoader.LoadSingleAppendOnlyFile(r.stat.AOFTimestamp)
if ret == AOFOK || ret == AOFTruncated {
log.Infof("The AOF File was successfully loaded\n")
log.Infof("The AOF File was successfully loaded")
} else {
log.Infof("There was an error opening the AOF File.\n")
log.Infof("There was an error opening the AOF File.")
}
log.Infof("Send single AOF finished. path=[%s]", r.path)
close(r.ch)
Expand All @@ -104,9 +104,9 @@ func (r *aofReader) StartRead() chan *entry.Entry {
aofLoader := NewAOFFileInfo(r.path, r.ch)
ret := aofLoader.LoadAppendOnlyFile(manifestInfo, r.ch, r.stat.AOFTimestamp, r.stat.FilterDangerousCommands)
if ret == AOFOK || ret == AOFTruncated {
log.Infof("The AOF File was successfully loaded\n")
log.Infof("The AOF File was successfully loaded")
} else {
log.Infof("There was an error opening the AOF File.\n")
log.Infof("There was an error opening the AOF File.")
}
log.Infof("Send multi-part AOF finished. path=[%s]", r.path)
close(r.ch)
Expand Down
Loading

0 comments on commit a1fa728

Please sign in to comment.