Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit eb8b1dd

Browse files
committed
Merge branch 'master' of github.com:jkcoxson/JitStreamer
2 parents ab37f79 + 10f1409 commit eb8b1dd

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/backend.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ impl Backend {
114114
.iter()
115115
.find(|client| client.ip == ip);
116116
match res {
117-
Some(c) => Some(c.to_client(&format!("{}/{}.plist", self.plist_storage, c.udid))),
117+
Some(c) => Some(c.to_client(&format!("{}/{}.plist", self.plist_storage, c.udid), &self.dmg_path)),
118118
None => None,
119119
}
120120
}
121121

122122
pub fn get_by_udid(&self, udid: &str) -> Option<Client> {
123123
let res = self.deserialized_clients.iter().find(|c| c.udid == udid);
124124
match res {
125-
Some(c) => Some(c.to_client(&format!("{}/{}.plist", self.plist_storage, c.udid))),
125+
Some(c) => Some(c.to_client(&format!("{}/{}.plist", self.plist_storage, c.udid), &self.dmg_path)),
126126
None => None,
127127
}
128128
}
@@ -179,11 +179,12 @@ pub struct DeserializedClient {
179179
}
180180

181181
impl DeserializedClient {
182-
pub fn to_client(&self, plist_path: &String) -> Client {
182+
pub fn to_client(&self, plist_path: &String, dmg_path: &String) -> Client {
183183
Client {
184184
ip: self.ip.clone(),
185185
udid: self.udid.clone(),
186186
pairing_file: plist_path.to_string(),
187+
dmg_path: dmg_path.to_string(),
187188
}
188189
}
189190
}

src/client.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1819
impl 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

Comments
 (0)