Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Drop use of FileExt #221

Merged
merged 1 commit into from
Jan 26, 2022
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
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ futures-util = "0.3.13"
gvariant = "0.4.0"
hex = "0.4.3"
indicatif = "0.16.0"
io-lifetimes = "0.4"
once_cell = "1.9"
libc = "0.2.92"
oci-spec = "0.5.4"
Expand Down
12 changes: 6 additions & 6 deletions lib/src/ima.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

use crate::objgv::*;
use anyhow::{Context, Result};
use cap_std_ext::rustix::fd::BorrowedFd;
use fn_error_context::context;
use gio::glib;
use gio::prelude::*;
use glib::Cast;
use glib::Variant;
use gvariant::aligned_bytes::TryAsAligned;
use gvariant::{gv, Marker, Structure};
use openat_ext::FileExt;
use io_lifetimes::AsFilelike;
use ostree::gio;
use std::collections::{BTreeMap, HashMap};
use std::ffi::CString;
use std::fs::File;
use std::ops::DerefMut;
use std::os::unix::io::AsRawFd;
use std::os::unix::prelude::{FromRawFd, IntoRawFd};
use std::process::{Command, Stdio};
use std::rc::Rc;
use std::{convert::TryInto, io::Seek};
Expand Down Expand Up @@ -122,10 +123,9 @@ impl<'a> CommitRewriter<'a> {
// If we're operating on a bare repo, we can clone the file (copy_file_range) directly.
if let Ok(instream) = instream.clone().downcast::<gio::UnixInputStream>() {
// View the fd as a File
let instream_fd = unsafe { File::from_raw_fd(instream.as_raw_fd()) };
instream_fd.copy_to(tempf.as_file_mut())?;
// Leak to avoid double close
let _ = instream_fd.into_raw_fd();
let instream_fd = unsafe { BorrowedFd::borrow_raw_fd(instream.as_raw_fd()) };
let instream_fd = &mut instream_fd.as_filelike_view::<File>();
std::io::copy(instream_fd.deref_mut(), tempf.as_file_mut())?;
} else {
// If we're operating on an archive repo, then we need to uncompress
// and recompress...
Expand Down