- Notifications
You must be signed in to change notification settings - Fork914
chore: file cache Release tied 1:1 with an acquire#18410
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Made idempotent
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.
It might be even more correct to have each file reference have someuuid
. Then we can be sure Aquire to Release is 1:1.
I did not want to refactor too much right now, so kept the underlying release mechanism the same.
type CloseFS struct { | ||
fs.FS | ||
close func() error | ||
} | ||
func (f *CloseFS) Close() error { return f.close() } |
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 named thisClose
to match the pattern of opening a file and deferring aClose
// | ||
// release should only be called after a successful call to Acquire using the Release() | ||
// method on the returned *CloseFS. | ||
func (c *Cache) release(fileID uuid.UUID) { |
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.
Unexported to force callers to use theClose
method for releasing.
Made idempotent