This commit is contained in:
Syfaro 2021-02-16 13:22:29 -05:00
parent 9f70ae0aca
commit 0453a84511
5 changed files with 384 additions and 819 deletions

1168
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,21 +5,20 @@ authors = ["Syfaro <syfaro@huefox.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
reqwest = { version = "*", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "0.2", features = ["full"] } tokio = { version = "1", features = ["full"] }
futures = { version = "*", features = ["thread-pool"] } futures = { version = "0.3", features = ["thread-pool"] }
hamming = "0.1.3" hamming = "0.1.3"
serde = "*" serde = "1"
serde_json = "*" serde_json = "1"
tokio-postgres = { version = "0.5.1", features = ["with-serde_json-1"] } tokio-postgres = { version = "0.7", features = ["with-serde_json-1"] }
bb8 = { git = "https://github.com/khuey/bb8.git" } bb8 = "0.7"
bb8-postgres = { git = "https://github.com/khuey/bb8.git" } bb8-postgres = "0.7"
furaffinity-rs = { git = "https://github.com/Syfaro/furaffinity-rs.git" }
image = "0.23" image = "0.23"
img_hash = "*" img_hash = "3"
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 2 opt-level = 2

View File

@ -124,7 +124,7 @@ async fn main() {
if elapsed < 1000 { if elapsed < 1000 {
let delay = 1000 - elapsed; let delay = 1000 - elapsed;
println!("delaying {}ms before loading next page", delay); println!("delaying {}ms before loading next page", delay);
tokio::time::delay_for(std::time::Duration::from_millis(delay)).await; tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
} }
} }
} }

View File

@ -7,6 +7,14 @@ struct NeededPost {
full_url: String, full_url: String,
} }
fn get_hasher() -> img_hash::Hasher<[u8; 8]> {
img_hash::HasherConfig::with_bytes_type::<[u8; 8]>()
.hash_alg(img_hash::HashAlg::Gradient)
.hash_size(8, 8)
.preproc_dct()
.to_hasher()
}
async fn hash_url( async fn hash_url(
id: i32, id: i32,
client: std::sync::Arc<reqwest::Client>, client: std::sync::Arc<reqwest::Client>,
@ -21,7 +29,7 @@ async fn hash_url(
.await .await
.expect("unable to get bytes"); .expect("unable to get bytes");
let hasher = furaffinity_rs::get_hasher(); let hasher = get_hasher();
let image = match image::load_from_memory(&data) { let image = match image::load_from_memory(&data) {
Ok(image) => image, Ok(image) => image,
Err(e) => { Err(e) => {
@ -100,7 +108,7 @@ async fn main() {
if needed_posts.is_empty() { if needed_posts.is_empty() {
println!("no posts, waiting a minute"); println!("no posts, waiting a minute");
tokio::time::delay_for(std::time::Duration::from_secs(60)).await; tokio::time::sleep(std::time::Duration::from_secs(60)).await;
continue; continue;
} }

View File

@ -165,7 +165,7 @@ async fn main() {
if elapsed < 1000 { if elapsed < 1000 {
let delay = 1000 - elapsed; let delay = 1000 - elapsed;
println!("delaying {}ms before loading next page", delay); println!("delaying {}ms before loading next page", delay);
tokio::time::delay_for(std::time::Duration::from_millis(delay)).await; tokio::time::sleep(std::time::Duration::from_millis(delay)).await;
} }
} }
} }