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}");
Ok(FileUploading {
path: self.path,
size,
uri: location,
offset: 0,
})
Ok(FileUploading::new(self.path, size, location))
}
}

View file

@ -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<Vec<u8>> {
let offset = u64::try_from(self.offset).map_err(io::Error::other)?;