From 66d6fdc1a64cf3659e936928bfe72e19d2ba73bb Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 17 Jul 2026 15:03:19 -0400 Subject: [PATCH] test(artwork): stop the blurhash worker before spec TempDir cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The artwork e2e suite stopped the worker via a DeferCleanup registered in setupHarness's BeforeEach, which Ginkgo runs LAST — after a spec body's own GinkgoT().TempDir() cleanups. With the cache disabled in these tests, every artwork serve now enqueues a blurhash recompute, so the worker can still be reading a spec-local sidecar file when its TempDir is removed. On Windows that unlink fails ("the process cannot access the file because it is being used by another process"), which flaked the playlist case-insensitive sidecar spec. Move the worker shutdown to a suite-level AfterEach, which runs before any spec-body DeferCleanup, so no artwork file is held open when TempDir removal runs. Close() is idempotent, so the change is safe across specs. --- core/artwork/e2e/suite_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/artwork/e2e/suite_test.go b/core/artwork/e2e/suite_test.go index 1ca4f2e2a..81bec7f52 100644 --- a/core/artwork/e2e/suite_test.go +++ b/core/artwork/e2e/suite_test.go @@ -58,6 +58,18 @@ var _ = AfterSuite(func() { db.Close(GinkgoT().Context()) }) +// AfterEach runs before any DeferCleanup a spec body registered, so it stops the blurhash worker +// before spec-local TempDirs are removed. On Windows a still-running worker can hold an artwork +// file open, and TempDir removal cannot unlink an open file. +var _ = AfterEach(func() { + if aw == nil { + return + } + if c, ok := aw.(io.Closer); ok { + Expect(c.Close()).To(Succeed()) + } +}) + func setupHarness() { DeferCleanup(configtest.SetupConfig()) @@ -89,8 +101,8 @@ func setupHarness() { storagetest.Register(fakeLibScheme, fakeFS) aw = artwork.NewArtwork(ds, artwork.GetImageCache(), newNoopFFmpeg(), &noopProvider{}) - // The worker must not outlive the spec: it would race the next spec's fakeFS/DB swaps. - DeferCleanup(aw.(io.Closer).Close) + // The worker is stopped by the suite-level AfterEach (which runs before spec-local TempDir + // cleanups), so it can't outlive the spec or hold a file open past TempDir removal. } func scan() {