11use super :: {
22 find_config_file, is_valid_project_name, load_mod_project, load_workshop_project,
3- CreateProjectArgs , FantomeImportProgress , FantomePeekResult , GitImportProgress ,
4- ImportFantomeArgs , ImportGitRepoArgs , SaveProjectConfigArgs , Workshop , WorkshopProject ,
3+ CreateProjectArgs , FantomeImportProgress , FantomeImportStage , FantomePeekResult ,
4+ GitImportProgress , GitImportStage , ImportFantomeArgs , ImportGitRepoArgs , SaveProjectConfigArgs ,
5+ Workshop , WorkshopProject ,
56} ;
67use crate :: error:: { AppError , AppResult } ;
78use crate :: state:: Settings ;
@@ -274,11 +275,21 @@ impl Workshop {
274275 fs:: create_dir_all ( & base_dir) ?;
275276
276277 for ( idx, wad_name) in wad_names. iter ( ) . enumerate ( ) {
277- self . emit_fantome_progress ( "extracting" , Some ( wad_name) , idx as u32 , total_wads) ;
278+ self . emit_fantome_progress (
279+ FantomeImportStage :: Extracting ,
280+ Some ( wad_name) ,
281+ idx as u32 ,
282+ total_wads,
283+ ) ;
278284 extract_fantome_wad ( & mut archive, wad_name, & base_dir) ?;
279285 }
280286
281- self . emit_fantome_progress ( "finalizing" , None , total_wads, total_wads) ;
287+ self . emit_fantome_progress (
288+ FantomeImportStage :: Finalizing ,
289+ None ,
290+ total_wads,
291+ total_wads,
292+ ) ;
282293
283294 let readme_path = project_dir. join ( "README.md" ) ;
284295 extract_fantome_file ( & mut archive, "meta/readme.md" , & readme_path) ;
@@ -336,13 +347,13 @@ impl Workshop {
336347 let config_path = project_dir. join ( "mod.config.json" ) ;
337348 fs:: write ( & config_path, serde_json:: to_string_pretty ( & mod_project) ?) ?;
338349
339- self . emit_fantome_progress ( "complete" , None , total_wads, total_wads) ;
350+ self . emit_fantome_progress ( FantomeImportStage :: Complete , None , total_wads, total_wads) ;
340351
341352 load_workshop_project ( & project_dir)
342353 } ) ( ) ;
343354
344355 if result. is_err ( ) {
345- self . emit_fantome_progress ( "error" , None , 0 , total_wads) ;
356+ self . emit_fantome_progress ( FantomeImportStage :: Error , None , 0 , total_wads) ;
346357 let _ = fs:: remove_dir_all ( & project_dir) ;
347358 }
348359
@@ -351,15 +362,15 @@ impl Workshop {
351362
352363 fn emit_fantome_progress (
353364 & self ,
354- stage : & str ,
365+ stage : FantomeImportStage ,
355366 current_wad : Option < & str > ,
356367 current : u32 ,
357368 total : u32 ,
358369 ) {
359370 let _ = self . app_handle . emit (
360371 "fantome-import-progress" ,
361372 FantomeImportProgress {
362- stage : stage . to_string ( ) ,
373+ stage,
363374 current_wad : current_wad. map ( String :: from) ,
364375 current,
365376 total,
@@ -480,7 +491,7 @@ impl Workshop {
480491 owner, repo, branch
481492 ) ;
482493
483- self . emit_git_progress ( "downloading" , None ) ;
494+ self . emit_git_progress ( GitImportStage :: Downloading , None ) ;
484495
485496 let response = reqwest:: blocking:: get ( & tarball_url)
486497 . map_err ( |e| AppError :: Other ( format ! ( "Failed to download repository: {}" , e) ) ) ?;
@@ -496,7 +507,7 @@ impl Workshop {
496507 . bytes ( )
497508 . map_err ( |e| AppError :: Other ( format ! ( "Failed to read response: {}" , e) ) ) ?;
498509
499- self . emit_git_progress ( "extracting" , None ) ;
510+ self . emit_git_progress ( GitImportStage :: Extracting , None ) ;
500511
501512 let temp_dir = workshop_path. join ( format ! ( ".git-import-{}" , uuid:: Uuid :: new_v4( ) ) ) ;
502513 fs:: create_dir_all ( & temp_dir) ?;
@@ -543,12 +554,12 @@ impl Workshop {
543554
544555 fs:: rename ( & extracted_dir, & project_dir) ?;
545556
546- self . emit_git_progress ( "complete" , None ) ;
557+ self . emit_git_progress ( GitImportStage :: Complete , None ) ;
547558 load_workshop_project ( & project_dir)
548559 } ) ( ) ;
549560
550561 if result. is_err ( ) {
551- self . emit_git_progress ( "error" , None ) ;
562+ self . emit_git_progress ( GitImportStage :: Error , None ) ;
552563 }
553564
554565 if temp_dir. exists ( ) {
@@ -557,11 +568,11 @@ impl Workshop {
557568 result
558569 }
559570
560- fn emit_git_progress ( & self , stage : & str , message : Option < & str > ) {
571+ fn emit_git_progress ( & self , stage : GitImportStage , message : Option < & str > ) {
561572 let _ = self . app_handle . emit (
562573 "git-import-progress" ,
563574 GitImportProgress {
564- stage : stage . to_string ( ) ,
575+ stage,
565576 message : message. map ( String :: from) ,
566577 } ,
567578 ) ;
0 commit comments