mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Fix race condition, introduced in the previous commit
This commit is contained in:
		@@ -28,7 +28,6 @@ func CreateInMemoryTexturesStorage() *inMemoryTexturesStorage {
 | 
				
			|||||||
	storage := &inMemoryTexturesStorage{
 | 
						storage := &inMemoryTexturesStorage{
 | 
				
			||||||
		data: make(map[string]*inMemoryItem),
 | 
							data: make(map[string]*inMemoryItem),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	storage.Start()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return storage
 | 
						return storage
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -178,6 +178,8 @@ func TestInMemoryTexturesStorage_GarbageCollection(t *testing.T) {
 | 
				
			|||||||
	storage.StoreTextures("dead24f9a4fa4877b7b04c8c6c72bb46", textures1)
 | 
						storage.StoreTextures("dead24f9a4fa4877b7b04c8c6c72bb46", textures1)
 | 
				
			||||||
	storage.StoreTextures("b5d58475007d4f9e9ddd1403e2497579", textures2)
 | 
						storage.StoreTextures("b5d58475007d4f9e9ddd1403e2497579", textures2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						storage.Start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	time.Sleep(inMemoryStorageGCPeriod + time.Millisecond) // Let it start first iteration
 | 
						time.Sleep(inMemoryStorageGCPeriod + time.Millisecond) // Let it start first iteration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_, textures1Err := storage.GetTextures("dead24f9a4fa4877b7b04c8c6c72bb46")
 | 
						_, textures1Err := storage.GetTextures("dead24f9a4fa4877b7b04c8c6c72bb46")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,11 +51,13 @@ var serveCmd = &cobra.Command{
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							texturesStorage := queue.CreateInMemoryTexturesStorage()
 | 
				
			||||||
 | 
							texturesStorage.Start()
 | 
				
			||||||
		mojangTexturesQueue := &queue.JobsQueue{
 | 
							mojangTexturesQueue := &queue.JobsQueue{
 | 
				
			||||||
			Logger: logger,
 | 
								Logger: logger,
 | 
				
			||||||
			Storage: &queue.SplittedStorage{
 | 
								Storage: &queue.SplittedStorage{
 | 
				
			||||||
				UuidsStorage:    mojangUuidsRepository,
 | 
									UuidsStorage:    mojangUuidsRepository,
 | 
				
			||||||
				TexturesStorage: queue.CreateInMemoryTexturesStorage(),
 | 
									TexturesStorage: texturesStorage,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		logger.Info("Mojang's textures queue is successfully initialized")
 | 
							logger.Info("Mojang's textures queue is successfully initialized")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user