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

Commitdb89836

Browse files
committed
hmm...
1 parent0fa1f6b commitdb89836

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

‎coderd/files/cache.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ func (c *Cache) Acquire(ctx context.Context, db database.Store, fileID uuid.UUID
160160

161161
// Check if the caller's context was canceled
162162
iferr:=ctx.Err();err!=nil {
163+
e.close()
163164
returnnil,err
164165
}
165166

166167
// Check that the caller is authorized to access the file
167168
subject,ok:=dbauthz.ActorFromContext(ctx)
168169
if!ok {
170+
e.close()
169171
returnnil,dbauthz.ErrNoActor
170172
}
171173
iferr:=c.authz.Authorize(ctx,subject,policy.ActionRead,ev.Object);err!=nil {
@@ -196,11 +198,6 @@ func (c *Cache) prepare(db database.Store, fileID uuid.UUID) *cacheEntry {
196198
hitLabel="false"
197199

198200
varpurgeOnce sync.Once
199-
purge:=func() {
200-
purgeOnce.Do(func() {
201-
c.purge(fileID)
202-
})
203-
}
204201
entry=&cacheEntry{
205202
refCount:0,
206203
value:lazy.NewWithError(func() (CacheEntryValue,error) {
@@ -226,10 +223,14 @@ func (c *Cache) prepare(db database.Store, fileID uuid.UUID) *cacheEntry {
226223
return
227224
}
228225

229-
purge()
226+
entry.purge()
230227
},
231228

232-
purge:purge,
229+
purge:func() {
230+
purgeOnce.Do(func() {
231+
c.purge(fileID)
232+
})
233+
},
233234
}
234235
c.data[fileID]=entry
235236

‎coderd/files/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func TestCancelledFetch(t *testing.T) {
6161
// First call that will fail
6262
wg.Add(1)
6363
gofunc() {
64-
close(rdy)
6564
_,err:=cache.Acquire(ctx,dbM,fileID)
65+
close(rdy)
6666
assert.ErrorIs(t,err,context.Canceled)
6767
wg.Done()
6868
}()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp