diff --git a/src/cachefile.rs b/src/cachefile.rs index 8a676b3..98cf19a 100644 --- a/src/cachefile.rs +++ b/src/cachefile.rs @@ -31,11 +31,11 @@ impl FileState { fn start_upload( self, http: &impl Client, - endpoint: &str, + endpoint: impl FnOnce() -> String, alias_id: &str, ) -> sharry::Result { match self { - FileState::C(checked) => checked.start_upload(http, endpoint, alias_id), + FileState::C(checked) => checked.start_upload(http, &endpoint(), alias_id), FileState::U(uploading) => Ok(uploading), } } @@ -105,11 +105,12 @@ impl CacheFile { pub fn pop_file(&mut self, http: &impl Client) -> Option { if let Some(state) = self.files.pop_front() { - let endpoint = self - .uri - .endpoint(format!("alias/upload/{}/files/tus", self.share_id)); + let endpoint = || { + self.uri + .endpoint(format!("alias/upload/{}/files/tus", self.share_id)) + }; // TODO somehow retry - Some(state.start_upload(http, &endpoint, &self.alias_id).unwrap()) // HACK unwrap + Some(state.start_upload(http, endpoint, &self.alias_id).unwrap()) // HACK unwrap } else { None }