From 21806b637a3b87d9dc7001076bfb0f1d6da5de4e Mon Sep 17 00:00:00 2001 From: buj Date: Sat, 7 Sep 2024 09:50:40 +0700 Subject: [PATCH] Fixed on Windows --- src/upload.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/upload.rs b/src/upload.rs index 06402b4..71e4b34 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -1,13 +1,17 @@ use std::{ fs::{self, File}, io::{Read, Write}, - os::unix::fs::MetadataExt, path::PathBuf, process::{Command, Stdio}, rc::Rc, sync::{atomic::AtomicU64, Mutex}, }; +#[cfg(unix)] +use std::os::unix::fs::MetadataExt; +#[cfg(windows)] +use std::os::windows::fs::MetadataExt; + use zip::{write::FileOptions, ZipWriter}; use crate::{ @@ -259,7 +263,16 @@ pub fn upload<'a, L: Logger>(config: &'a Config, log: &'a mut L) { match file.metadata() { Ok(x) => { let mut volume = 0; - let mut size = x.size() as f32; + let mut size = { + #[cfg(unix)] + { + x.size() + } + #[cfg(windows)] + { + x.file_size() + } + } as f32; while size >= 1024.0 && volume < volumes.len() - 1 { size /= 1024.0; volume += 1;