Fix timer going awry

This commit is contained in:
Deluan
2023-01-17 22:04:04 -05:00
parent feb774a149
commit 580e9ae4bd
5 changed files with 14 additions and 21 deletions
+2 -1
View File
@@ -65,10 +65,11 @@ func (a *cacheWarmer) sendWakeSignal() {
func (a *cacheWarmer) run(ctx context.Context) {
for {
time.AfterFunc(10*time.Second, func() {
t := time.AfterFunc(10*time.Second, func() {
a.sendWakeSignal()
})
<-a.wakeSignal
t.Stop()
// If cache not available, keep waiting
if !a.cache.Available(ctx) {
+1 -1
View File
@@ -27,7 +27,7 @@ var _ = Describe("MediaStreamer", func() {
{ID: "123", Path: "tests/fixtures/test.mp3", Suffix: "mp3", BitRate: 128, Duration: 257.0},
})
testCache := GetTranscodingCache()
Eventually(func() bool { return testCache.Ready(context.TODO()) }).Should(BeTrue())
Eventually(func() bool { return testCache.Available(context.TODO()) }).Should(BeTrue())
})
AfterEach(func() {
_ = os.RemoveAll(conf.Server.DataFolder)
+1 -1
View File
@@ -30,7 +30,7 @@ var _ = Describe("MediaStreamer", func() {
{ID: "123", Path: "tests/fixtures/test.mp3", Suffix: "mp3", BitRate: 128, Duration: 257.0},
})
testCache := core.GetTranscodingCache()
Eventually(func() bool { return testCache.Ready(context.TODO()) }).Should(BeTrue())
Eventually(func() bool { return testCache.Available(context.TODO()) }).Should(BeTrue())
streamer = core.NewMediaStreamer(ds, ffmpeg, testCache)
})
AfterEach(func() {