Get file hash, size.

This commit is contained in:
Syfaro 2020-09-06 15:40:25 -04:00
parent b6b21c4ee6
commit 04506fbd53
2 changed files with 7 additions and 4 deletions

3
Cargo.lock generated
View File

@ -398,7 +398,7 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]] [[package]]
name = "furaffinity-rs" name = "furaffinity-rs"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/Syfaro/furaffinity-rs#3e17efcbc75f18f11e425eacb4bfafcceff4be72" source = "git+https://github.com/Syfaro/furaffinity-rs#6ebc01a0e45b9067bd25e5dbd624b9a6dffb8658"
dependencies = [ dependencies = [
"cfscrape", "cfscrape",
"chrono", "chrono",
@ -408,6 +408,7 @@ dependencies = [
"regex", "regex",
"reqwest", "reqwest",
"scraper", "scraper",
"sha2",
"tokio", "tokio",
] ]

View File

@ -83,8 +83,10 @@ async fn insert_submission(
let hash = sub.hash.clone(); let hash = sub.hash.clone();
let url = sub.content.url(); let url = sub.content.url();
client.execute("INSERT INTO submission (id, artist_id, url, filename, hash, rating, posted_at, description, hash_int, file_id) VALUES ($1, $2, $3, $4, decode($5, 'base64'), $6, $7, $8, $9, CASE WHEN isnumeric(split_part($4, '.', 1)) THEN split_part($4, '.', 1)::int ELSE null END)", &[ let size = sub.file_size.map(|size| size as i32);
&sub.id, &artist_id, &url, &sub.filename, &hash, &sub.rating.serialize(), &sub.posted_at, &sub.description, &sub.hash_num,
client.execute("INSERT INTO submission (id, artist_id, url, filename, hash, rating, posted_at, description, hash_int, file_id, file_size, file_sha256) VALUES ($1, $2, $3, $4, decode($5, 'base64'), $6, $7, $8, $9, CASE WHEN isnumeric(split_part($4, '.', 1)) THEN split_part($4, '.', 1)::int ELSE null END, $10, $11)", &[
&sub.id, &artist_id, &url, &sub.filename, &hash, &sub.rating.serialize(), &sub.posted_at, &sub.description, &sub.hash_num, &size, &sub.file_sha256,
]).await?; ]).await?;
let stmt = client let stmt = client
@ -133,7 +135,7 @@ async fn request(
async fn web() { async fn web() {
use hyper::service::{make_service_fn, service_fn}; use hyper::service::{make_service_fn, service_fn};
let addr = ([127, 0, 0, 1], 3000).into(); let addr: std::net::SocketAddr = std::env::var("HTTP_HOST").unwrap().parse().unwrap();
let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(request)) }); let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(request)) });