Skip to content

Commit 6a8e98d

Browse files
committed
Fix panic when processing malformed appstream refs
1 parent bd971f1 commit 6a8e98d

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
@@ -159,7 +159,22 @@ impl CommitJobInstance {
159159
fs::create_dir_all(&appstream_dir)?;
160160
let appstream_refs = ostree::list_refs(&build_repo_path, "appstream");
161161
for appstream_ref in appstream_refs {
162-
let arch = appstream_ref.split('/').nth(1).unwrap();
162+
job_log_and_info!(
163+
self.job_id,
164+
conn,
165+
&format!("Processing appstream ref: {}", appstream_ref)
166+
);
167+
let arch = match appstream_ref.split('/').nth(1) {
168+
Some(a) => a,
169+
None => {
170+
job_log_and_info!(
171+
self.job_id,
172+
conn,
173+
&format!("Skipping malformed appstream ref: {}", appstream_ref)
174+
);
175+
continue;
176+
}
177+
};
163178
let mut cmd = Command::new("ostree");
164179
cmd.arg(format!("--repo={}", &build_repo_path.to_str().unwrap()))
165180
.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)