@@ -119,30 +119,38 @@ export class GameDatabaseChart extends GameDatabaseEngine {
119119 } ) ;
120120 }
121121 }
122-
122+
123+ const chartInfosLegit : TChartInfo [ ] = [ ] ;
123124 // Push files to chart info
124125 for ( const chartInfo of chartInfos ) {
125- chartInfo . chart = supportedFiles . find ( ( e ) => e . filename === chartInfo . chart ) ! . md5 ;
126- chartInfo . audio = supportedFiles . find ( ( e ) => e . filename === chartInfo . audio ) ! . md5 ;
127- chartInfo . image = supportedFiles . find ( ( e ) => e . filename === chartInfo . image ) ! . md5 ;
126+ const chartFileInfo = supportedFiles . find ( ( e ) => e . filename === chartInfo . chart ) ;
127+ const audioFileInfo = supportedFiles . find ( ( e ) => e . filename === chartInfo . audio ) ;
128+ const imageFileInfo = supportedFiles . find ( ( e ) => e . filename === chartInfo . image ) ;
129+
130+ if ( ! chartFileInfo || ! audioFileInfo || ! imageFileInfo ) continue ;
131+
132+ chartInfo . chart = chartFileInfo . md5 ;
133+ chartInfo . audio = audioFileInfo . md5 ;
134+ chartInfo . image = imageFileInfo . md5 ;
128135
129136 chartInfo . extraFiles = [ ...supportedFiles
130137 . filter ( ( e ) => e . md5 !== chartInfo . chart )
131138 . filter ( ( e ) => e . md5 !== chartInfo . audio )
132139 . filter ( ( e ) => e . md5 !== ( chartInfo . image || '' ) )
133140 . map ( ( e ) => e . md5 )
134141 ] ;
142+ chartInfosLegit . push ( chartInfo ) ;
135143 }
136144
137145 // Save chart info to dabatase
138- for ( const info of chartInfos ) {
146+ for ( const info of chartInfosLegit ) {
139147 if ( ! ( await this . get ( info . chart ) ) ) this . add ( info ) ;
140148 }
141149
142150 res ( {
143151 files : supportedFiles ,
144152 decodedFiles,
145- infos : chartInfos ,
153+ infos : chartInfosLegit ,
146154 } ) ;
147155 } ) }
148156
0 commit comments