From d327cb9203ce1d8ad304bf608f0cf4d7e7722237 Mon Sep 17 00:00:00 2001 From: Igor <85039990+igoracmelo@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:41:50 -0300 Subject: [PATCH] FindByCRC: match only once (#540) --- dat/dat.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dat/dat.go b/dat/dat.go index 8276357..083402c 100644 --- a/dat/dat.go +++ b/dat/dat.go @@ -70,6 +70,7 @@ func (db *DB) FindByCRC(romPath string, romName string, crc uint32, size int64, return } + once := sync.Once{} var wg sync.WaitGroup wg.Add(len(*db)) // For every Dat in the DB @@ -82,9 +83,11 @@ func (db *DB) FindByCRC(romPath string, romName string, crc uint32, size int64, } // If the checksums and sizes match if crc == uint32(game.ROMs[0].CRC) && size == game.ROMs[0].Size { - game.Path = romPath - game.System = system - games <- game + once.Do(func() { + game.Path = romPath + game.System = system + games <- game + }) } } wg.Done()