lockfile: Be robust to non-seconds-since-epoch repodata
We should really have safety comments around our use of `.unwrap()`. This Google kubernetes rpm-md repo appears to use seconds-since-epoch. We could try to detect that, probably best done in libdnf. I think it'd be better to get them to match the informal schema for this actually though instead. For now let's just log an error and not crash. Closes: https://github.com/coreos/rpm-ostree/issues/2600
This commit is contained in:
parent
f882d6ddff
commit
49c55089d2
@ -273,12 +273,21 @@ mod ffi {
|
|||||||
let repo_ref = unsafe { &mut *rpmmd_repo };
|
let repo_ref = unsafe { &mut *rpmmd_repo };
|
||||||
let id = dnf_repo_get_id(repo_ref).unwrap();
|
let id = dnf_repo_get_id(repo_ref).unwrap();
|
||||||
let generated = dnf_repo_get_timestamp_generated(repo_ref).unwrap();
|
let generated = dnf_repo_get_timestamp_generated(repo_ref).unwrap();
|
||||||
lockfile_repos.insert(
|
let generated: i64 = match generated.try_into() {
|
||||||
id,
|
Ok(t) => t,
|
||||||
LockfileRepoMetadata {
|
Err(e) => {
|
||||||
generated: Utc.timestamp(generated.try_into().unwrap(), 0),
|
eprintln!("Invalid rpm-md repo {} timestamp: {}: {}", id, generated, e);
|
||||||
},
|
0
|
||||||
);
|
}
|
||||||
|
};
|
||||||
|
let generated = match Utc.timestamp_opt(generated, 0) {
|
||||||
|
chrono::offset::LocalResult::Single(t) => t,
|
||||||
|
_ => {
|
||||||
|
eprintln!("Invalid rpm-md repo {} timestamp: {}", id, generated);
|
||||||
|
Utc.timestamp(0, 0)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
lockfile_repos.insert(id, LockfileRepoMetadata { generated });
|
||||||
}
|
}
|
||||||
|
|
||||||
int_glib_error(
|
int_glib_error(
|
||||||
|
Loading…
Reference in New Issue
Block a user