diff --git a/src/main.rs b/src/main.rs index 2de5b9f..9e3b80d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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( diff --git a/src/preload.rs b/src/preload.rs index ed9d002..5133421 100644 --- a/src/preload.rs +++ b/src/preload.rs @@ -8,7 +8,7 @@ pub struct Preload { } impl Preload { - pub fn init(directory: &str, regex: Option<&str>, clear: bool) -> Result { + pub fn init(directory: &str, regex: Option, clear: bool) -> Result { 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()), }) }