diff --git a/src/cachefile.rs b/src/cachefile.rs index 1910959..05c3fc3 100644 --- a/src/cachefile.rs +++ b/src/cachefile.rs @@ -181,7 +181,7 @@ impl CacheFile { .take() .expect("abort_upload called while not uploading"); - self.files.push_front(upl.into()); + self.files.push_front(upl.stop()); } pub fn share_notify(&self, client: &impl Client) -> crate::Result<()> { diff --git a/src/file/chunk.rs b/src/file/chunk.rs index e78252e..a2d2eb0 100644 --- a/src/file/chunk.rs +++ b/src/file/chunk.rs @@ -2,13 +2,18 @@ use std::fmt; use crate::sharry; +/// Chunk of binary data belonging to a currently uploading file pub struct Chunk<'t> { + /// id of the associated file file_id: sharry::FileID, + /// offset of this chunk in bytes offset: u64, + /// data inside this chunk data: &'t [u8], } impl fmt::Debug for Chunk<'_> { + // chunks are 1 MiB or more, we shouldn't print that fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Chunk") .field("file_id", &self.file_id) diff --git a/src/file/uploading.rs b/src/file/uploading.rs index 74a82db..a751497 100644 --- a/src/file/uploading.rs +++ b/src/file/uploading.rs @@ -32,12 +32,6 @@ pub struct Uploading { offset: u64, } -impl From for Checked { - fn from(value: Uploading) -> Self { - Self::new_direct(value.path, value.size, value.hash) - } -} - impl Uploading { pub(super) fn new_direct( path: PathBuf, @@ -118,6 +112,13 @@ impl Uploading { Err(self.path) } } + + /// stop uploading this file + /// + /// - consume self, returning as a `file::Checked` + pub fn stop(self) -> Checked { + Checked::new_direct(self.path, self.size, self.hash) + } } impl FileTrait for Uploading {