feat: add build_with_client method to RustyPipeBuilder
fix: create data dir if it doesn't exist
This commit is contained in:
parent
43ed52daf9
commit
43ef8d15c4
2 changed files with 7 additions and 2 deletions
|
|
@ -393,7 +393,7 @@ async fn main() {
|
|||
|
||||
let mut storage_dir = dirs::data_dir().expect("no data dir");
|
||||
storage_dir.push("rustypipe");
|
||||
_ = std::fs::create_dir(&storage_dir);
|
||||
std::fs::create_dir_all(&storage_dir).expect("could not create data dir");
|
||||
|
||||
let mut rp = RustyPipe::builder().storage_dir(storage_dir);
|
||||
if cli.report {
|
||||
|
|
|
|||
|
|
@ -458,7 +458,12 @@ impl RustyPipeBuilder {
|
|||
|
||||
/// Return a new, configured RustyPipe instance.
|
||||
pub fn build(self) -> Result<RustyPipe, Error> {
|
||||
let mut client_builder = ClientBuilder::new()
|
||||
self.build_with_client(ClientBuilder::new())
|
||||
}
|
||||
|
||||
/// Return a new, configured RustyPipe instance using a Reqwest client builder.
|
||||
pub fn build_with_client(self, mut client_builder: ClientBuilder) -> Result<RustyPipe, Error> {
|
||||
client_builder = client_builder
|
||||
.user_agent(self.user_agent.unwrap_or_else(|| DEFAULT_UA.to_owned()))
|
||||
.gzip(true)
|
||||
.brotli(true)
|
||||
|
|
|
|||
Reference in a new issue