Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion contrib/packaging/bootc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ cat >%{?buildroot}/%{system_reinstall_bootc_install_podman_path} <<EOF
exec dnf -y install podman
EOF
chmod +x %{?buildroot}/%{system_reinstall_bootc_install_podman_path}
# generate doc file list excluding directories
# generate doc file list excluding directories; workaround for
# https://github.com/coreos/rpm-ostree/issues/5420
touch %{?buildroot}/%{_docdir}/bootc/baseimage/base/sysroot/.keepdir
find %{?buildroot}/%{_docdir} ! -type d -printf '%{_docdir}/%%P\n' > bootcdoclist.txt

Expand Down
13 changes: 7 additions & 6 deletions ostree-ext/src/tar/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> {
fn write_parents_of(
&mut self,
path: &Utf8Path,
root: &gio::File,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Passing the root object here allows the function to resolve paths relative to the commit, avoiding redundant loading of the commit object in each recursive call.

cache: &mut HashSet<Utf8PathBuf>,
) -> Result<()> {
let Some(parent) = path.parent() else {
Expand All @@ -654,15 +655,11 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> {
return Ok(());
}

self.write_parents_of(parent, cache)?;
self.write_parents_of(parent, root, cache)?;
Comment on lines 657 to +658

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By passing the root, you've ensured that each recursive call uses the same root file, preventing redundant loads.


let inserted = cache.insert(parent.to_owned());
debug_assert!(inserted);

let root = self
.repo
.read_commit(&self.commit_checksum, gio::Cancellable::NONE)?
.0;
let parent_file = root.resolve_relative_path(unmap_path(parent).as_ref());
let queryattrs = "unix::*";
let queryflags = gio::FileQueryInfoFlags::NOFOLLOW_SYMLINKS;
Expand Down Expand Up @@ -733,13 +730,17 @@ fn write_chunk<W: std::io::Write>(
create_parent_dirs: bool,
) -> Result<()> {
let mut cache = std::collections::HashSet::new();
let root = writer
.repo
.read_commit(&writer.commit_checksum, gio::Cancellable::NONE)?
.0;
Comment on lines +733 to +736

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Moving the read_commit call here ensures that it's only called once per chunk, which reduces the number of calls to the repository.

for (checksum, (_size, paths)) in chunk.into_iter() {
let (objpath, h) = writer.append_content(checksum.borrow())?;
for path in paths.iter() {
let path = path_for_tar_v1(path);
let h = h.clone();
if create_parent_dirs {
writer.write_parents_of(&path, &mut cache)?;
writer.write_parents_of(&path, &root, &mut cache)?;
}
writer.append_content_hardlink(&objpath, h, path)?;
}
Expand Down