From 7afc7d8f901d3caed481acd68b56de9083920662 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 2 Aug 2025 14:44:55 +0300 Subject: [PATCH] use redb index, update db revision --- Cargo.toml | 3 ++- src/main.rs | 14 ++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 939f1ad..4775992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,5 +23,6 @@ urlencoding = "2.1" yggtracker-redb = "0.1" [patch.crates-io] -yggtracker-redb = { git = "https://github.com/YGGverse/yggtracker-redb.git", rev="008402696d81c4b7d4cc7786c9cf3263ae8632b6" } +# yggtracker-redb = { path = "../yggtracker-redb" } +yggtracker-redb = { git = "https://github.com/YGGverse/yggtracker-redb.git", rev="e6cdd9c41df4a90c45bf3be2e605a2efb83585b7" } librqbit = { git = "https://github.com/ikatson/rqbit.git", rev="b580a9610ae7c6eaacd305a3905f7e2d3202ca69" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 07a8ab7..61b6bb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,8 +72,6 @@ async fn main() -> Result<()> { // begin println!("Crawler started on {time_init}"); - let mut processed = HashSet::with_capacity(config.index_capacity); - loop { let time_queue = Local::now(); if config.debug { @@ -100,7 +98,7 @@ async fn main() -> Result<()> { // convert to string once let i = i.to_string(); // already indexed? - if processed.contains(&i) { + if database.torrent(&i)?.is_some() { continue; } if config.debug { @@ -163,12 +161,6 @@ async fn main() -> Result<()> { } if info.relative_filename.extension().is_none_or(|e| !matches!(e.as_bytes(), b"png" | b"jpeg" | b"jpg" | b"gif" | b"webp")) { - if config.debug { - println!( - "\t\t\tskip non-image file `{}` for `{i}`.", - info.relative_filename.to_string_lossy() - ) - } continue; } if preload.max_filesize.is_some_and(|limit| info.len > limit) { @@ -259,8 +251,6 @@ async fn main() -> Result<()> { if config.debug { println!("\t\t\tadd `{i}` to index.") } - // skip processed torrent on the next iteration - assert!(processed.insert(i)) } Ok(_) => panic!(), Err(e) => eprintln!("Failed to resolve `{i}`: `{e}`."), @@ -276,7 +266,7 @@ async fn main() -> Result<()> { if config.debug { println!( "Queue completed on {time_queue}\n\ttotal: {}\n\ttime: {} s\n\tuptime: {} s\n\tawait {} seconds to continue...", - processed.len(), + database.torrents_total()?, Local::now() .signed_duration_since(time_queue) .as_seconds_f32(),