From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A23AC1FF15E for ; Mon, 27 Oct 2025 14:25:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E6D45F04; Mon, 27 Oct 2025 14:26:13 +0100 (CET) From: Filip Schauer To: pbs-devel@lists.proxmox.com Date: Mon, 27 Oct 2025 14:24:44 +0100 Message-ID: <20251027132450.101103-3-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251027132450.101103-1-f.schauer@proxmox.com> References: <20251027132450.101103-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761571527894 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.006 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox v5 2/5] compression: zip: add support for symlinks X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Filip Schauer --- proxmox-compression/src/zip.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs index e67613e4..d7bdd296 100644 --- a/proxmox-compression/src/zip.rs +++ b/proxmox-compression/src/zip.rs @@ -17,7 +17,7 @@ use std::time::SystemTime; use anyhow::{format_err, Error, Result}; use endian_trait::Endian; use futures::ready; -use libc::{S_IFDIR, S_IFREG}; +use libc::{S_IFDIR, S_IFLNK, S_IFREG}; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf}; use crc32fast::Hasher; @@ -76,6 +76,7 @@ fn epoch_to_dos(epoch: i64) -> (u16, u16) { pub enum FileType { Directory, Regular, + Symlink, } #[derive(Endian)] @@ -236,6 +237,7 @@ impl ZipEntry { mode |= match file_type { FileType::Regular => S_IFREG, FileType::Directory => S_IFDIR, + FileType::Symlink => S_IFLNK, } as u16; Self { @@ -656,7 +658,8 @@ where let encoder = &mut encoder; let entry = async move { - let entry_path_no_base = entry.path().strip_prefix(base_path)?; + let entrypath = entry.path(); + let entry_path_no_base = entrypath.strip_prefix(base_path)?; let metadata = entry.metadata()?; let mtime = match metadata .modified() @@ -669,13 +672,18 @@ where let mode = metadata.mode() as u16; if entry.file_type().is_file() { - let file = tokio::fs::File::open(entry.path()).await?; + let file = Box::new(tokio::fs::File::open(entrypath).await?); let ze = ZipEntry::new(entry_path_no_base, mtime, mode, FileType::Regular); - Ok(Some((ze, Some(file)))) + Ok(Some((ze, Some::>(file)))) } else if entry.file_type().is_dir() { let ze = ZipEntry::new(entry_path_no_base, mtime, mode, FileType::Directory); - let content: Option = None; - Ok(Some((ze, content))) + Ok(Some((ze, None))) + } else if entry.file_type().is_symlink() { + let target: Box = Box::new(io::Cursor::new( + entrypath.read_link()?.into_os_string().into_encoded_bytes(), + )); + let ze = ZipEntry::new(entry_path_no_base, mtime, mode, FileType::Symlink); + Ok(Some((ze, Some(target)))) } else { // ignore other file types Ok::<_, Error>(None) -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel