mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-20 20:03:48 +01:00
refactor: undo send archive changes
This commit is contained in:
parent
31f74cff65
commit
9ad691ee94
1 changed files with 4 additions and 8 deletions
|
@ -86,7 +86,7 @@ impl AsyncRead for TarReader {
|
||||||
enum ArchiveEntryInner {
|
enum ArchiveEntryInner {
|
||||||
Tar(Box<tokio_tar::Entry<tokio_tar::Archive<TarReader>>>),
|
Tar(Box<tokio_tar::Entry<tokio_tar::Archive<TarReader>>>),
|
||||||
Zip {
|
Zip {
|
||||||
archive: ArchivePointer,
|
archive: *mut async_zip::tokio::read::seek::ZipFileReader<std::io::Cursor<Vec<u8>>>,
|
||||||
reader: ManuallyDrop<
|
reader: ManuallyDrop<
|
||||||
Compat<
|
Compat<
|
||||||
async_zip::tokio::read::ZipEntryReader<
|
async_zip::tokio::read::ZipEntryReader<
|
||||||
|
@ -105,7 +105,7 @@ impl Drop for ArchiveEntryInner {
|
||||||
Self::Tar(_) => {}
|
Self::Tar(_) => {}
|
||||||
Self::Zip { archive, reader } => unsafe {
|
Self::Zip { archive, reader } => unsafe {
|
||||||
ManuallyDrop::drop(reader);
|
ManuallyDrop::drop(reader);
|
||||||
drop(Box::from_raw(archive.0));
|
drop(Box::from_raw(*archive));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,10 +131,6 @@ impl AsyncRead for ArchiveEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ArchivePointer(*mut async_zip::tokio::read::seek::ZipFileReader<std::io::Cursor<Vec<u8>>>);
|
|
||||||
|
|
||||||
unsafe impl Send for ArchivePointer {}
|
|
||||||
|
|
||||||
impl Archive {
|
impl Archive {
|
||||||
/// Finds the executable in the archive and returns it as an [`ArchiveEntry`]
|
/// Finds the executable in the archive and returns it as an [`ArchiveEntry`]
|
||||||
pub async fn find_executable(
|
pub async fn find_executable(
|
||||||
|
@ -273,8 +269,8 @@ impl Archive {
|
||||||
|
|
||||||
let path: &Path = entry.filename().as_str()?.as_ref();
|
let path: &Path = entry.filename().as_str()?.as_ref();
|
||||||
if candidate.path == path {
|
if candidate.path == path {
|
||||||
let ptr = ArchivePointer(Box::into_raw(Box::new(archive)));
|
let ptr = Box::into_raw(Box::new(archive));
|
||||||
let reader = (unsafe { &mut *ptr.0 }).reader_without_entry(i).await?;
|
let reader = (unsafe { &mut *ptr }).reader_without_entry(i).await?;
|
||||||
return Ok(ArchiveEntry(ArchiveEntryInner::Zip {
|
return Ok(ArchiveEntry(ArchiveEntryInner::Zip {
|
||||||
archive: ptr,
|
archive: ptr,
|
||||||
reader: ManuallyDrop::new(reader.compat()),
|
reader: ManuallyDrop::new(reader.compat()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue