FileUploading::new

This commit is contained in:
Jörn-Michael Miehe 2025-06-04 16:58:18 +00:00
parent 9c2fdd95c6
commit cf84eed717
2 changed files with 14 additions and 10 deletions

View file

@ -66,11 +66,6 @@ impl FileChecked {
debug!("patch uri: {location}"); debug!("patch uri: {location}");
Ok(FileUploading { Ok(FileUploading::new(self.path, size, location))
path: self.path,
size,
uri: location,
offset: 0,
})
} }
} }

View file

@ -15,10 +15,10 @@ use super::{Alias, SharryAlias};
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct FileUploading { pub struct FileUploading {
pub(super) path: PathBuf, path: PathBuf,
pub(super) size: usize, size: usize,
pub(super) uri: String, uri: String,
pub(super) offset: usize, offset: usize,
} }
#[derive(Debug)] #[derive(Debug)]
@ -36,6 +36,15 @@ pub enum ChunkState {
} }
impl FileUploading { 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<Vec<u8>> { fn read_chunk(&self, chunk_size: usize) -> io::Result<Vec<u8>> {
let offset = u64::try_from(self.offset).map_err(io::Error::other)?; let offset = u64::try_from(self.offset).map_err(io::Error::other)?;