feat(server): working archive upload for non-any architecture
This commit is contained in:
parent
eb9f6a5cb1
commit
c2f35aebac
6 changed files with 283 additions and 39 deletions
|
|
@ -68,7 +68,7 @@ impl ReadFilter {
|
|||
ReadFilter::Bzip2 => Some(".bz2"),
|
||||
ReadFilter::Lzma => Some(".lzma"),
|
||||
ReadFilter::Xz => Some(".xz"),
|
||||
ReadFilter::Zstd => Some(".zstd"),
|
||||
ReadFilter::Zstd => Some(".zst"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -308,6 +308,12 @@ pub trait Entry {
|
|||
ffi::archive_entry_set_pathname(self.entry_mut(), c_str.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
fn set_mode(&mut self, mode: u32) {
|
||||
unsafe {
|
||||
ffi::archive_entry_set_mode(self.entry_mut(), mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
pub mod archive;
|
||||
pub mod error;
|
||||
pub mod read;
|
||||
mod write;
|
||||
pub mod write;
|
||||
|
||||
pub use archive::{
|
||||
Entry, ExtractOption, ExtractOptions, Handle, ReadCompression, ReadFilter, ReadFormat,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use super::WriteEntry;
|
||||
use crate::error::ArchiveError;
|
||||
use crate::Entry;
|
||||
use crate::Handle;
|
||||
use libarchive3_sys::ffi;
|
||||
use libarchive3_sys::ffi::c_void;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
|
|
@ -37,7 +37,10 @@ impl FileWriter {
|
|||
path: P,
|
||||
) -> io::Result<()> {
|
||||
unsafe {
|
||||
ffi::archive_write_header(self.handle_mut(), entry.entry_mut());
|
||||
match ffi::archive_write_header(self.handle_mut(), entry.entry_mut()) {
|
||||
ffi::ARCHIVE_OK => (),
|
||||
_ => return Err(ArchiveError::from(self as &dyn Handle).into()),
|
||||
}
|
||||
}
|
||||
|
||||
let mut f = fs::File::open(path)?;
|
||||
|
|
@ -47,7 +50,15 @@ impl FileWriter {
|
|||
match f.read(&mut buf) {
|
||||
Ok(0) => return Ok(()),
|
||||
Ok(written) => unsafe {
|
||||
ffi::archive_write_data(self.handle_mut(), buf.as_ptr() as *const _, written);
|
||||
match ffi::archive_write_data(
|
||||
self.handle_mut(),
|
||||
buf.as_ptr() as *const _,
|
||||
written,
|
||||
) as i32
|
||||
{
|
||||
ffi::ARCHIVE_OK => (),
|
||||
_ => return Err(ArchiveError::from(self as &dyn Handle).into()),
|
||||
};
|
||||
},
|
||||
Err(err) => match err.kind() {
|
||||
io::ErrorKind::Interrupted => (),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue