@@ -69,29 +69,8 @@ impl ScanService {
6969
7070 let run_started = Instant :: now ( ) ;
7171 let bundle_path = bundle_path. as_ref ( ) ;
72- let run = match engine. run ( bundle_path) {
73- Ok ( run) => run,
74- Err ( OrchestratorError :: AppBundleNotFound )
75- if is_zip_like ( bundle_path) =>
76- {
77- match extract_app_bundle ( bundle_path) {
78- Ok ( ( dir, app_path) ) => {
79- let run = engine
80- . run_on_bundle ( & app_path, run_started)
81- . map_err ( |err| ScanError :: ScanFailed ( err. to_string ( ) ) ) ?;
82- std:: mem:: drop ( dir) ;
83- run
84- }
85- Err ( err) => {
86- return Err ( ScanError :: ScanFailed ( format ! (
87- "{}. If you only have a .app, zip it and upload the .zip" ,
88- err
89- ) ) ) ;
90- }
91- }
92- }
93- Err ( err) => return Err ( ScanError :: ScanFailed ( err. to_string ( ) ) ) ,
94- } ;
72+ let run = engine. run ( bundle_path)
73+ . map_err ( |err| ScanError :: ScanFailed ( err. to_string ( ) ) ) ?;
9574
9675 let mut report = build_report ( run. results , run. total_duration_ms , run. cache_stats ) ;
9776 let baseline = request. baseline . as_ref ( ) . map ( |baseline| apply_baseline ( & mut report, baseline) ) ;
@@ -137,41 +116,7 @@ fn build_rule_selection(
137116 } )
138117}
139118
140- fn is_zip_like ( path : & Path ) -> bool {
141- path. extension ( )
142- . and_then ( |ext| ext. to_str ( ) )
143- . is_some_and ( |ext| ext. eq_ignore_ascii_case ( "zip" ) || ext. eq_ignore_ascii_case ( "ipa" ) )
144- }
145119
146- fn extract_app_bundle ( path : & Path ) -> Result < ( tempfile:: TempDir , PathBuf ) , String > {
147- let file = std:: fs:: File :: open ( path) . map_err ( |err| err. to_string ( ) ) ?;
148- let mut archive = ZipArchive :: new ( file) . map_err ( |err| err. to_string ( ) ) ?;
149- let dir = tempfile:: tempdir ( ) . map_err ( |err| err. to_string ( ) ) ?;
150- archive
151- . extract ( dir. path ( ) )
152- . map_err ( |err| err. to_string ( ) ) ?;
153-
154- let app_path = find_app_bundle ( dir. path ( ) )
155- . ok_or_else ( || "Could not locate .app in uploaded archive" . to_string ( ) ) ?;
156- Ok ( ( dir, app_path) )
157- }
158-
159- fn find_app_bundle ( root : & Path ) -> Option < PathBuf > {
160- let mut queue = vec ! [ root. to_path_buf( ) ] ;
161- while let Some ( dir) = queue. pop ( ) {
162- let entries = std:: fs:: read_dir ( & dir) . ok ( ) ?;
163- for entry in entries. flatten ( ) {
164- let path = entry. path ( ) ;
165- if path. is_dir ( ) {
166- if path. extension ( ) . is_some_and ( |ext| ext == "app" ) {
167- return Some ( path) ;
168- }
169- queue. push ( path) ;
170- }
171- }
172- }
173- None
174- }
175120
176121fn load_xcode_project (
177122 path : & Path ,
0 commit comments