Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Dec 11, 2016

cache: put cache data after writing the data successfully

This patch changes the cache data to put after writing the data to local or peers successfully.
As current code put the cache before writing the data, it causes conflict when the writing the data failed.

if len(peers.Peers) == 0 {
return torus.ErrOutOfSpace
}
d.readCache.Put(string(i.ToBytes()), data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var err error

defer func() {
   if err == nil {
       d.readCache.Put(...)
   }
}

@xiang90
Copy link
Contributor

xiang90 commented Dec 12, 2016

How did you spot this bug? do you mind adding a test for this?

@nak3
Copy link
Contributor Author

nak3 commented Dec 15, 2016

Thank you. I updated. Sure, I can add a test for this. But it looks like I should wait for #359, as some test utilities would be added.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants