mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
test(artwork): stop the blurhash worker before spec TempDir cleanup
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.
This commit is contained in:
parent
3759488db5
commit
66d6fdc1a6
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user