@@ -13,15 +13,17 @@ pub struct Client {
1313 pub ip : String ,
1414 pub udid : String ,
1515 pub pairing_file : String ,
16+ pub dmg_path : String ,
1617}
1718
1819impl Client {
1920 #[ allow( dead_code) ]
20- pub fn new ( ip : String , udid : String , pairing_file : String ) -> Client {
21+ pub fn new ( ip : String , udid : String , pairing_file : String , dmg_path : String ) -> Client {
2122 Client {
2223 ip,
2324 udid,
2425 pairing_file,
26+ dmg_path,
2527 }
2628 }
2729
@@ -304,18 +306,11 @@ impl Client {
304306 pub async fn get_dmg_path ( & self ) -> Result < String , String > {
305307 let ios_version = self . get_ios_version ( ) . await ?;
306308
307- // Get current directory
308- let current_dir = match std:: env:: current_dir ( ) {
309- Ok ( dir) => dir. canonicalize ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) ,
310- Err ( _) => {
311- return Err ( "Unable to get current directory" . to_string ( ) ) ;
312- }
313- } ;
314-
315309 // Check if directory exists
316- let path = format ! ( "{}/dmg/{}.dmg" , & current_dir, & ios_version) ;
317- if std:: path:: Path :: new ( & path) . exists ( ) {
318- return Ok ( path) ;
310+ let path = std:: path:: Path :: new ( & self . dmg_path ) . join ( format ! ( "{}.dmg" , & ios_version) ) ;
311+ debug ! ( "Checking if {} exists" , path. display( ) ) ;
312+ if path. exists ( ) {
313+ return Ok ( String :: from ( path. to_string_lossy ( ) ) ) ;
319314 }
320315 // Download versions.json from GitHub
321316 debug ! ( "Downloading iOS dictionary..." ) ;
@@ -366,7 +361,7 @@ impl Client {
366361 }
367362 } ;
368363 // Create tmp path
369- let tmp_path = format ! ( "{}/dmg/ tmp" , & current_dir ) ;
364+ let tmp_path = format ! ( "{}/tmp" , & self . dmg_path ) ;
370365 debug ! ( "tmp path {}" , tmp_path) ;
371366 std:: fs:: create_dir_all ( & tmp_path) . unwrap ( ) ;
372367 // Unzip zip
@@ -398,11 +393,11 @@ impl Client {
398393 }
399394 // Move DMG to JIT Shipper directory
400395 let ios_dmg = dmg_path. join ( "DeveloperDiskImage.dmg" ) ;
401- std:: fs:: rename ( ios_dmg, format ! ( "{}/dmg/ {}.dmg" , & current_dir , ios_version) ) . unwrap ( ) ;
396+ std:: fs:: rename ( ios_dmg, format ! ( "{}/{}.dmg" , & self . dmg_path , ios_version) ) . unwrap ( ) ;
402397 let ios_sig = dmg_path. join ( "DeveloperDiskImage.dmg.signature" ) ;
403398 std:: fs:: rename (
404399 ios_sig,
405- format ! ( "{}/dmg/ {}.dmg.signature" , & current_dir , ios_version) ,
400+ format ! ( "{}/{}.dmg.signature" , & self . dmg_path , ios_version) ,
406401 )
407402 . unwrap ( ) ;
408403
@@ -414,7 +409,7 @@ impl Client {
414409 ) ;
415410
416411 // Return DMG path
417- Ok ( format ! ( "{}/dmg/ {}.dmg" , & current_dir , ios_version) )
412+ Ok ( format ! ( "{}/{}.dmg" , & self . dmg_path , ios_version) )
418413 }
419414
420415 pub async fn upload_dev_dmg ( & self ) -> Result < ( ) , String > {
@@ -465,6 +460,8 @@ impl Client {
465460 }
466461 } ;
467462
463+ debug ! ( "Uploading DMG from: {}" , dmg_path) ;
464+ debug ! ( "signature: {}" , format!( "{}.signature" , dmg_path. clone( ) ) . to_string( ) ) ;
468465 match mim. upload_image (
469466 dmg_path. clone ( ) ,
470467 "Developer" . to_string ( ) ,
0 commit comments