Remove rand from the downloader.
This commit is contained in:
parent
6336f7cac1
commit
7eff93ecf1
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -571,7 +571,6 @@ dependencies = [
|
||||
"hyper 0.11.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"reqwest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -46,7 +46,7 @@ Flatpak instructions... Soon™.
|
||||
|
||||
### Dependancies
|
||||
|
||||
* Rust stable 1.21 or later.
|
||||
* Rust stable 1.22 or later.
|
||||
* Gtk+ 3.22 or later
|
||||
* Meson
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@ lazy_static! {
|
||||
}
|
||||
|
||||
pub fn connection() -> Pool {
|
||||
// Arc::clone(&DB)
|
||||
Arc::clone(&POOL)
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ error-chain = "0.11.0"
|
||||
hyper = "0.11.7"
|
||||
log = "0.3.8"
|
||||
mime_guess = "1.8.2"
|
||||
rand = "0.3.18"
|
||||
reqwest = "0.8.1"
|
||||
tempdir = "0.3.5"
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use reqwest;
|
||||
use hyper::header::*;
|
||||
use tempdir::TempDir;
|
||||
use rand;
|
||||
use rand::Rng;
|
||||
use mime_guess;
|
||||
|
||||
use std::fs::{rename, DirBuilder, File};
|
||||
@ -62,13 +60,8 @@ fn download_into(dir: &str, file_title: &str, url: &str) -> Result<String> {
|
||||
|
||||
// Construct a temp file to save desired content.
|
||||
let tempdir = TempDir::new_in(dir, "")?;
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let out_file = format!(
|
||||
"{}/{}.part",
|
||||
tempdir.path().to_str().unwrap(),
|
||||
rng.gen::<usize>()
|
||||
);
|
||||
let out_file = format!("{}/temp.part", tempdir.path().to_str().unwrap(),);
|
||||
|
||||
// Save requested content into the file.
|
||||
save_io(&out_file, &mut resp, ct_len)?;
|
||||
@ -142,11 +135,7 @@ pub fn get_episode(ep: &mut Episode, download_folder: &str) -> Result<()> {
|
||||
}
|
||||
|
||||
pub fn cache_image(pd: &Podcast) -> Option<String> {
|
||||
if pd.image_uri().is_none() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let url = pd.image_uri().unwrap().to_owned();
|
||||
let url = pd.image_uri()?.to_owned();
|
||||
if url == "" {
|
||||
return None;
|
||||
}
|
||||
@ -159,6 +148,7 @@ pub fn cache_image(pd: &Podcast) -> Option<String> {
|
||||
|
||||
// Hacky way
|
||||
// TODO: make it so it returns the first cover.* file encountered.
|
||||
// Use glob instead
|
||||
let png = format!("{}/cover.png", download_fold);
|
||||
let jpg = format!("{}/cover.jpg", download_fold);
|
||||
let jpe = format!("{}/cover.jpe", download_fold);
|
||||
|
||||
@ -8,7 +8,6 @@ extern crate hyper;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate mime_guess;
|
||||
extern crate rand;
|
||||
extern crate reqwest;
|
||||
extern crate tempdir;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user