take regex config value

This commit is contained in:
yggverse 2025-07-07 12:33:54 +03:00
parent bd49ae8c6f
commit c34f435153
2 changed files with 3 additions and 3 deletions

View file

@ -33,7 +33,7 @@ async fn main() -> Result<()> {
let peers = peers::Peers::init(&config.initial_peer)?;
let preload = config
.preload
.map(|ref p| Preload::init(p, config.preload_regex.as_deref(), config.clear).unwrap());
.map(|ref p| Preload::init(p, config.preload_regex, config.clear).unwrap());
let trackers = Trackers::init(&config.tracker)?;
let torrent = config.export_torrents.map(|p| Torrent::init(&p).unwrap());
let session = librqbit::Session::new_with_opts(

View file

@ -8,7 +8,7 @@ pub struct Preload {
}
impl Preload {
pub fn init(directory: &str, regex: Option<&str>, clear: bool) -> Result<Self> {
pub fn init(directory: &str, regex: Option<String>, clear: bool) -> Result<Self> {
let path = PathBuf::from_str(directory)?;
if let Ok(t) = fs::metadata(&path) {
if t.is_file() {
@ -28,7 +28,7 @@ impl Preload {
fs::create_dir_all(&path)?;
Ok(Self {
path,
regex: regex.map(|r| Regex::new(r).unwrap()),
regex: regex.map(|r| Regex::new(&r).unwrap()),
})
}