Skip to content

Commit 4654615

Browse files
authored
fix(oma-refresh): fix /var/lib/dpkg/arch file is empty will only fetch binary-all packages metadata (#333)
1 parent 5abc323 commit 4654615

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

oma-refresh/src/db.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,19 @@ impl<'a> OmaRefresh<'a> {
755755

756756
let index_target_config = IndexTargetConfig::new(self.apt_config, &self.arch);
757757

758-
let archs_from_file = fs::read_to_string("/var/lib/dpkg/arch")
759-
.await
760-
.map(|f| f.lines().map(|x| x.to_string()).collect::<Vec<_>>());
758+
let archs_from_file = fs::read_to_string("/var/lib/dpkg/arch").await;
759+
760+
let archs_from_file = if let Ok(file) = archs_from_file {
761+
let res = file.lines().map(|x| x.to_string()).collect::<Vec<_>>();
762+
763+
if res.is_empty() {
764+
None
765+
} else {
766+
Some(res)
767+
}
768+
} else {
769+
None
770+
};
761771

762772
let mut flat_repo_no_release = vec![];
763773

@@ -813,7 +823,7 @@ impl<'a> OmaRefresh<'a> {
813823

814824
let mut archs = if let Some(archs) = ose.archs() {
815825
archs.iter().map(|x| x.as_str()).collect::<Vec<_>>()
816-
} else if let Ok(ref f) = archs_from_file {
826+
} else if let Some(ref f) = archs_from_file {
817827
f.iter().map(|x| x.as_str()).collect::<Vec<_>>()
818828
} else {
819829
vec![self.arch.as_str()]

0 commit comments

Comments
 (0)