Skip to content
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

try to prevent being stuck forever if cache file gets corrupted #13

Merged
merged 1 commit into from Aug 2, 2019

Conversation

@kjk
Copy link
Contributor

kjk commented Aug 2, 2019

If .fuzzit.cache gets corrupted so that it can't be json-decoded, fuzzit auth will be stuck forever.

Try to prevent that by deleting the file if it fails decoding.

if err != nil {
return err
}
defer file.Close()

This comment has been minimized.

Copy link
@yevgenypats

yevgenypats Aug 2, 2019

Collaborator

Why this line is removed?

This comment has been minimized.

Copy link
@kjk

kjk Aug 2, 2019

Author Contributor

It's moved after json.NewDecoder() because on e.g. windows one cannot remove opened file so we have to call file.Close() before os.Remove() and defer file.Close() means it would be called after.

This comment has been minimized.

Copy link
@yevgenypats

yevgenypats Aug 2, 2019

Collaborator

Got it. nice!

@yevgenypats yevgenypats merged commit 2038de3 into fuzzitdev:master Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.