Skip to content

Commit f872fe4

Browse files
committed
Fix race condition, introduced in the previous commit
1 parent 5b4761e commit f872fe4

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

api/mojang/queue/in_memory_textures_storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func CreateInMemoryTexturesStorage() *inMemoryTexturesStorage {
2828
storage := &inMemoryTexturesStorage{
2929
data: make(map[string]*inMemoryItem),
3030
}
31-
storage.Start()
3231

3332
return storage
3433
}

api/mojang/queue/in_memory_textures_storage_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ func TestInMemoryTexturesStorage_GarbageCollection(t *testing.T) {
178178
storage.StoreTextures("dead24f9a4fa4877b7b04c8c6c72bb46", textures1)
179179
storage.StoreTextures("b5d58475007d4f9e9ddd1403e2497579", textures2)
180180

181+
storage.Start()
182+
181183
time.Sleep(inMemoryStorageGCPeriod + time.Millisecond) // Let it start first iteration
182184

183185
_, textures1Err := storage.GetTextures("dead24f9a4fa4877b7b04c8c6c72bb46")

cmd/serve.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ var serveCmd = &cobra.Command{
5151
return
5252
}
5353

54+
texturesStorage := queue.CreateInMemoryTexturesStorage()
55+
texturesStorage.Start()
5456
mojangTexturesQueue := &queue.JobsQueue{
5557
Logger: logger,
5658
Storage: &queue.SplittedStorage{
5759
UuidsStorage: mojangUuidsRepository,
58-
TexturesStorage: queue.CreateInMemoryTexturesStorage(),
60+
TexturesStorage: texturesStorage,
5961
},
6062
}
6163
logger.Info("Mojang's textures queue is successfully initialized")

0 commit comments

Comments
 (0)