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

Commit3f3e201

Browse files
authored
fix: fix http cache dir creation order in coderdtest (#17303)
fixescoder/internal#565Fixes the ordering of creating the HTTP cache temp dir with respect tostarting the Coderd HTTP server, so that they are cleaned up in thecorrect (reverse) order.
1 parent43b1a03 commit3f3e201

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎coderd/coderdtest/coderdtest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
405405
workspacestats.TrackerWithTickFlush(options.WorkspaceUsageTrackerTick,options.WorkspaceUsageTrackerFlush),
406406
)
407407

408+
// create the TempDir for the HTTP file cache BEFORE we start the server and set a t.Cleanup to close it. TempDir()
409+
// registers a Cleanup function that deletes the directory, and Cleanup functions are called in reverse order. If
410+
// we don't do this, then we could try to delete the directory before the HTTP server is done with all files in it,
411+
// which on Windows will fail (can't delete files until all programs have closed handles to them).
412+
cacheDir:=t.TempDir()
413+
408414
varmutex sync.RWMutex
409415
varhandler http.Handler
410416
srv:=httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
@@ -515,7 +521,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
515521
AppHostname:options.AppHostname,
516522
AppHostnameRegex:appHostnameRegex,
517523
Logger:*options.Logger,
518-
CacheDir:t.TempDir(),
524+
CacheDir:cacheDir,
519525
RuntimeConfig:runtimeManager,
520526
Database:options.Database,
521527
Pubsub:options.Pubsub,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp