Skip to content

Commit e65bc24

Browse files
committed
Fix panic when processing malformed appstream refs
1 parent 6d89fa1 commit e65bc24

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/jobs/commit_job.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,22 @@ impl CommitJobInstance {
152152
fs::create_dir_all(&appstream_dir)?;
153153
let appstream_refs = ostree::list_refs(&build_repo_path, "appstream");
154154
for appstream_ref in appstream_refs {
155-
let arch = appstream_ref.split('/').nth(1).unwrap();
155+
job_log_and_info!(
156+
self.job_id,
157+
conn,
158+
&format!("Processing appstream ref: {}", appstream_ref)
159+
);
160+
let arch = match appstream_ref.split('/').nth(1) {
161+
Some(a) => a,
162+
None => {
163+
job_log_and_info!(
164+
self.job_id,
165+
conn,
166+
&format!("Skipping malformed appstream ref: {}", appstream_ref)
167+
);
168+
continue;
169+
}
170+
};
156171
let mut cmd = Command::new("ostree");
157172
cmd.arg(format!("--repo={}", &build_repo_path.to_str().unwrap()))
158173
.arg("checkout")

src/jobs/update_repo_job.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,22 @@ impl UpdateRepoJobInstance {
238238
let appstream_dir = repo_path.join("appstream");
239239
let appstream_refs = ostree::list_refs(&repoconfig.path, "appstream");
240240
for appstream_ref in appstream_refs {
241-
let arch = appstream_ref.split('/').nth(1).unwrap();
241+
job_log_and_info!(
242+
self.job_id,
243+
conn,
244+
&format!("Processing appstream ref: {}", appstream_ref)
245+
);
246+
let arch = match appstream_ref.split('/').nth(1) {
247+
Some(a) => a,
248+
None => {
249+
job_log_and_info!(
250+
self.job_id,
251+
conn,
252+
&format!("Skipping malformed appstream ref: {}", appstream_ref)
253+
);
254+
continue;
255+
}
256+
};
242257
let mut cmd = Command::new("ostree");
243258
cmd.arg(format!("--repo={}", &repoconfig.path.to_str().unwrap()))
244259
.arg("checkout")

0 commit comments

Comments
 (0)