Skip to content

Commit 6acc948

Browse files
committed
Revert "Use list_static_delta_names for delta listing"
1 parent afbf230 commit 6acc948

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ serde = "1.0"
1212
serde_derive = "1.0"
1313
serde_json = "1.0"
1414
thiserror = "2"
15+
walkdir = "2"

common/src/ostree.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::os::fd::AsRawFd;
66
use std::path::{self, Path};
77
use std::{fs, io};
88
use thiserror::Error;
9+
use walkdir::WalkDir;
910

1011
#[derive(Error, Debug, Clone, Eq, PartialEq)]
1112
pub enum OstreeError {
@@ -328,18 +329,27 @@ impl std::fmt::Display for Delta {
328329
}
329330

330331
pub fn list_deltas(repo_path: &path::Path) -> Vec<Delta> {
331-
let repo = match open_repo(repo_path) {
332-
Ok(repo) => repo,
333-
Err(_e) => return Vec::new(),
334-
};
335-
let names = match repo.list_static_delta_names(gio::Cancellable::NONE) {
336-
Ok(names) => names,
337-
Err(_e) => return Vec::new(),
338-
};
332+
let deltas_dir = get_deltas_path(repo_path);
339333

340-
names
341-
.iter()
342-
.filter_map(|name| Delta::from_name(name.as_str()).ok())
334+
WalkDir::new(deltas_dir)
335+
.min_depth(2)
336+
.max_depth(2)
337+
.into_iter()
338+
.filter_map(|e| e.ok())
339+
.filter(|e| e.file_type().is_dir())
340+
.map(|e| {
341+
format!(
342+
"{}{}",
343+
e.path()
344+
.parent()
345+
.unwrap()
346+
.file_name()
347+
.unwrap()
348+
.to_string_lossy(),
349+
e.file_name().to_string_lossy()
350+
)
351+
})
352+
.filter_map(|name| Delta::from_name(&name).ok())
343353
.collect()
344354
}
345355

0 commit comments

Comments
 (0)