Optimize rocksdb

This commit is contained in:
2025-10-26 01:31:57 +08:00
parent 9f6c81471e
commit da3acaaacb
6 changed files with 60 additions and 31 deletions

View File

@@ -1,5 +1,8 @@
pub mod db;
use std::path::PathBuf;
use color_eyre::eyre::eyre;
use color_eyre::owo_colors::OwoColorize;
use tokio::fs;
use crate::constants::{APP_CONFIG_DIR, APP_DATA_DIR, APP_DB_DATA_DIR};
use crate::crawler::DLSITE_IMG_FOLDER;
@@ -19,4 +22,20 @@ pub async fn initialize_folders() -> color_eyre::Result<()> {
fs::create_dir_all(APP_DB_DATA_DIR.as_path()).await?;
}
Ok(())
}
pub async fn get_all_folders(paths: &Vec<PathBuf>) -> color_eyre::Result<Vec<PathBuf>> {
let mut folders: Vec<PathBuf> = Vec::new();
for path in paths {
let path = path.as_path();
if !path.exists() {
return Err(eyre!("{:?} {}", path.blue(), "does not exist".red()));
}
let mut dirs = fs::read_dir(path).await?;
while let Some(dir) = dirs.next_entry().await? {
folders.push(dir.path());
}
}
Ok(folders)
}