Skip to content

Commit

Permalink
add unix permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Maneren committed Aug 24, 2024
1 parent 732a4bc commit 3d19e23
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fileserv/archive.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::items_after_statements)]

use std::{fmt, path::Path};

use async_compression::tokio::write::{GzipEncoder, ZstdEncoder};
Expand Down Expand Up @@ -242,6 +244,19 @@ where

let entry = ZipEntryBuilder::new(zip_name, Compression::Deflate);

cfg_if! { if #[cfg(target_family = "unix")] {
use std::os::unix::fs::PermissionsExt as _;
#[allow(clippy::cast_possible_truncation)]
let entry = entry.unix_permissions(
file
.metadata()
.await
.map_err(|e| Error::Io(format!("Failed to get metadata for {}", path.display()), e))?
.permissions()
.mode() as u16
);
}}

let mut sink = zip.write_entry_stream(entry).await.map_err(|e| {
Error::ArchiveCreation(
format!("Failed to write {} to the ZIP archive", name.display()),
Expand Down

0 comments on commit 3d19e23

Please sign in to comment.