Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit610740a

Browse files
committed
proper release gating
1 parentbf6562a commit610740a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

‎coderd/files/cache.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,20 @@ func (c *Cache) prepare(ctx context.Context, db database.Store, fileID uuid.UUID
194194
hitLabel="false"
195195

196196
varreleaseOnce sync.Once
197+
release:=func() {
198+
releaseOnce.Do(func() {
199+
c.purge(fileID)
200+
})
201+
}
197202
entry=&cacheEntry{
198203
refCount:0,
199204
value:lazy.NewWithError(func() (CacheEntryValue,error) {
200205
val,err:=fetch(db,fileID)
201206
iferr!=nil {
202207
// Force future calls to Acquire to trigger a new fetch as soon as
203208
// a fetch has failed, even if references are still held.
204-
delete(c.data,fileID)
209+
entry.close()
210+
release()
205211
returnval,err
206212
}
207213

@@ -218,12 +224,11 @@ func (c *Cache) prepare(ctx context.Context, db database.Store, fileID uuid.UUID
218224

219225
entry.refCount--
220226
c.currentOpenFileReferences.Dec()
221-
222-
ifentry.refCount==0 {
223-
releaseOnce.Do(func() {
224-
c.purge(fileID)
225-
})
227+
ifentry.refCount>0 {
228+
return
226229
}
230+
231+
release()
227232
},
228233
}
229234
c.data[fileID]=entry

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp