diff --git a/src/cachefile.rs b/src/cachefile.rs index 15b18e9..36fed9c 100644 --- a/src/cachefile.rs +++ b/src/cachefile.rs @@ -169,23 +169,22 @@ impl CacheFile { } pub fn rewind_chunk(mut self) -> Option { - self.uploading = Some( - self.uploading - .take() - .expect("rewind_chunk called while not uploading") - .rewind()?, - ); + let upl = self + .uploading + .take() + .expect("rewind_chunk called while not uploading"); + self.uploading = Some(upl.rewind()?); Some(self) } pub fn abort_upload(&mut self) { - self.files.push_front( - self.uploading - .take() - .expect("abort_upload called while not uploading") - .abort(), - ); + let upl = self + .uploading + .take() + .expect("abort_upload called while not uploading"); + + self.files.push_front(upl.abort()); } pub fn share_notify(&self, client: &impl Client) -> crate::Result<()> { diff --git a/src/file/uploading.rs b/src/file/uploading.rs index 290f494..8ac6eea 100644 --- a/src/file/uploading.rs +++ b/src/file/uploading.rs @@ -46,13 +46,11 @@ impl Uploading { self.offset } - pub fn rewind(self) -> Option { + pub fn rewind(mut self) -> Option { if let Some(last_offset) = self.last_offset { - Some(Self { - last_offset: None, - offset: last_offset, - ..self - }) + self.last_offset = None; + self.offset = last_offset; + Some(self) } else { warn!("attempted to rewind twice"); None