@@ -117,7 +117,6 @@ pub async fn parse_and_import_dat_file(
117117 } )
118118 . collect ( ) ;
119119
120- // Delete existing files that are not in the new files
121120 for file in existing_files. iter ( ) {
122121 let identifier = (
123122 & file. file_name ,
@@ -134,7 +133,6 @@ pub async fn parse_and_import_dat_file(
134133
135134 let mut to_insert = vec ! [ ] ;
136135
137- // Insert new files that are not in the existing files
138136 for rom in game. rom . iter ( ) {
139137 let identifier = (
140138 & rom. name ,
@@ -217,10 +215,9 @@ fn parse_company_and_platform(
217215) -> anyhow:: Result < ( Option < String > , String , Vec < String > ) > {
218216 let mut dat_header = dat. header . name . clone ( ) ;
219217
220- // Remove Arcade - from the name as its not a company or system
218+ // Remove Arcade - from the name because it is not a company or system
221219 dat_header = dat_header. replace ( "Arcade - " , "" ) ;
222220
223- // Remove subset prefix if present
224221 if let Some ( subset) = & dat. header . subset {
225222 let subset_prefix = format ! ( "{subset} - " ) ;
226223 if dat_header. starts_with ( & subset_prefix) {
@@ -241,25 +238,21 @@ fn parse_company_and_platform(
241238
242239 match split. len ( ) {
243240 1 => {
244- // Single part - it's the platform, no company
245241 platform = split[ 0 ] . to_string ( ) ;
246242 }
247243 2 => {
248- // Two parts - company and platform
249244 company = Some ( split[ 0 ] . to_string ( ) ) ;
250245 platform = split[ 1 ] . to_string ( ) ;
251246 }
252247 _ => {
253- // Three or more parts
254248 company = Some ( split[ 0 ] . to_string ( ) ) ;
255249
256- // Join the remaining parts
257250 let remaining_parts = split[ 1 ..] . to_vec ( ) ;
258251
259- // Check if this looks like extra metadata (contains brackets, "NKit", etc)
252+ // Stop joining parts onto the platform once one looks like extra
253+ // metadata (bracketed tags, NKit, RVZ, and similar).
260254 let mut platform_parts = Vec :: new ( ) ;
261255 for part in remaining_parts {
262- // Stop adding to platform if we hit what looks like metadata
263256 if part. contains ( '[' )
264257 || part. contains ( "NKit" )
265258 || part. contains ( "RVZ" )
@@ -282,10 +275,8 @@ fn parse_company_and_platform(
282275
283276 // Remove company name from platform if it appears there for GameCube
284277 if let Some ( ref company_name) = company {
285- // Remove "Company Platform" -> "Platform"
286278 if platform. starts_with ( company_name) && platform. to_lowercase ( ) . contains ( "gamecube" ) {
287279 let after_company = platform. strip_prefix ( company_name) . unwrap_or ( & platform) ;
288- // Clean up any leading spaces or separators
289280 platform = after_company
290281 . trim_start_matches ( ' ' )
291282 . trim_start_matches ( '-' )
@@ -297,7 +288,6 @@ fn parse_company_and_platform(
297288 let company_no_spaces = company_name. replace ( ' ' , "" ) ;
298289 if platform. starts_with ( & company_no_spaces) && platform. len ( ) > company_no_spaces. len ( ) {
299290 let potential_platform = & platform[ company_no_spaces. len ( ) ..] ;
300- // Check if the next character is uppercase (indicating camelCase split)
301291 if potential_platform
302292 . chars ( )
303293 . next ( )
@@ -309,10 +299,8 @@ fn parse_company_and_platform(
309299 }
310300 }
311301
312- // Remove version from platform if present
313302 platform = platform. replace ( & format ! ( " ({version})" ) , "" ) ;
314303
315- // Extract tags from platform
316304 let mut clean_platform = platform. clone ( ) ;
317305 for capture in DAT_TAG_REGEX . captures_iter ( & platform) {
318306 if let Some ( tag_match) = capture. get ( 1 ) {
@@ -337,7 +325,6 @@ fn parse_company_and_platform(
337325 let number_str = number_match. as_str ( ) ;
338326 let number = number_str. parse :: < u32 > ( ) . unwrap_or ( 1 ) ;
339327
340- // Convert PS1, PS2, PS3, etc. to PlayStation 1, PlayStation 2, etc.
341328 platform = format ! ( "PlayStation {number}" ) ;
342329 }
343330
0 commit comments