-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[check-log] Ignore broken/unexpected json on reading state #302
Conversation
@@ -444,6 +451,8 @@ func getStateFile(stateDir, f string, args []string) string { | |||
) | |||
} | |||
|
|||
var errValidStateFileNotFound = fmt.Errorf("state file not found, or corrupted") | |||
|
|||
func getBytesToSkip(f string) (int64, error) { | |||
state, err := loadState(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If state file is corrupted, loadState()
will return nil, nil
.
Is it intended behavior that getBytesToSkipOld
will be called to try to read old state file in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the behavior is not the best but acceptable.
But finally I decided not to read old state file the case faeb49f
if !opts.NoState { | ||
s, err := getBytesToSkip(stateFile) | ||
if err != nil { | ||
return 0, 0, "", err | ||
if err != errValidStateFileNotFound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getBytesToSkip
can return errValidStateFileNotFound
only if getBytesToSkipOld
is called.
I'm not sure this is the best approach, but worth consider…