From cf84eed717739484e129fd2893d728f038aa458e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 4 Jun 2025 16:58:18 +0000 Subject: [PATCH] FileUploading::new --- src/sharry/file/checked.rs | 7 +------ src/sharry/file/uploading.rs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/sharry/file/checked.rs b/src/sharry/file/checked.rs index 87e6054..166e940 100644 --- a/src/sharry/file/checked.rs +++ b/src/sharry/file/checked.rs @@ -66,11 +66,6 @@ impl FileChecked { debug!("patch uri: {location}"); - Ok(FileUploading { - path: self.path, - size, - uri: location, - offset: 0, - }) + Ok(FileUploading::new(self.path, size, location)) } } diff --git a/src/sharry/file/uploading.rs b/src/sharry/file/uploading.rs index eebd8b1..7cfd393 100644 --- a/src/sharry/file/uploading.rs +++ b/src/sharry/file/uploading.rs @@ -15,10 +15,10 @@ use super::{Alias, SharryAlias}; #[derive(Serialize, Deserialize, Debug)] pub struct FileUploading { - pub(super) path: PathBuf, - pub(super) size: usize, - pub(super) uri: String, - pub(super) offset: usize, + path: PathBuf, + size: usize, + uri: String, + offset: usize, } #[derive(Debug)] @@ -36,6 +36,15 @@ pub enum ChunkState { } impl FileUploading { + pub(super) fn new(path: PathBuf, size: usize, uri: String) -> Self { + Self { + path, + size, + uri, + offset: 0, + } + } + fn read_chunk(&self, chunk_size: usize) -> io::Result> { let offset = u64::try_from(self.offset).map_err(io::Error::other)?;