]> OzVa Git service - ozva-cloud/commitdiff
fix: incorrect seperator for zip archives under windows (#577)
authorMatthias Möller <m_moeller@live.de>
Fri, 25 Apr 2025 00:14:21 +0000 (02:14 +0200)
committerGitHub <noreply@github.com>
Fri, 25 Apr 2025 00:14:21 +0000 (08:14 +0800)
src/server.rs

index ef9cf4943cb68c8551ee7a2a117eb897af188bd6..97c8d56bb8e7f60e141e2fe234acbba4ae92a708 100644 (file)
@@ -37,7 +37,7 @@ use std::collections::HashMap;
 use std::fs::Metadata;
 use std::io::SeekFrom;
 use std::net::SocketAddr;
-use std::path::{Component, Path, PathBuf};
+use std::path::{Component, Path, PathBuf, MAIN_SEPARATOR};
 use std::sync::atomic::{self, AtomicBool};
 use std::sync::Arc;
 use std::time::SystemTime;
@@ -1644,7 +1644,12 @@ async fn zip_dir<W: AsyncWrite + Unpin>(
     ))
     .await?;
     for zip_path in zip_paths.into_iter() {
-        let filename = match zip_path.strip_prefix(dir).ok().and_then(|v| v.to_str()) {
+        let filename = match zip_path
+            .strip_prefix(dir)
+            .ok()
+            .and_then(|v| v.to_str())
+            .map(|v| v.replace(MAIN_SEPARATOR, "/"))
+        {
             Some(v) => v,
             None => continue,
         };