Fix seed finder
This commit is contained in:
parent
173b8a4de1
commit
f6efc7a4e5
|
@ -1,11 +1,13 @@
|
|||
use clap::Parser;
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::ffi::OsStr;
|
||||
|
||||
use env_logger::Env;
|
||||
|
||||
use anyhow::{anyhow, bail, Context};
|
||||
|
||||
use colour::{dark_green_ln, dark_yellow, green, yellow_ln};
|
||||
use log::warn;
|
||||
use reqwest::{Client, Url};
|
||||
use std::path::PathBuf;
|
||||
use tokio::sync::mpsc;
|
||||
|
@ -56,6 +58,9 @@ pub async fn main() -> anyhow::Result<()> {
|
|||
let (seed_tx, seed_rx) = mpsc::channel(128);
|
||||
|
||||
let seed_files = find_seed_files(config.seed_dir.clone()).await?;
|
||||
|
||||
eprintln!("{:?}", seed_files);
|
||||
|
||||
tokio::spawn(async move {
|
||||
seed_loader(seed_files, &seed_tx).await?;
|
||||
|
||||
|
@ -155,10 +160,21 @@ async fn find_seed_files(seed_dir: PathBuf) -> anyhow::Result<Vec<PathBuf>> {
|
|||
|
||||
while let Some(entry) = dir.next_entry().await? {
|
||||
let path = entry.path();
|
||||
if path.starts_with(".") {
|
||||
let file_name = match path
|
||||
.file_name()
|
||||
.map(|osstr: &OsStr| osstr.to_str())
|
||||
.flatten()
|
||||
{
|
||||
None => {
|
||||
warn!("Skipping non-UTF-8 name.");
|
||||
continue;
|
||||
}
|
||||
if path.ends_with(".seed") {
|
||||
Some(file_name) => file_name,
|
||||
};
|
||||
if file_name.starts_with(".") {
|
||||
continue;
|
||||
}
|
||||
if file_name.ends_with(".seed") {
|
||||
seedfiles.push(path);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue