From 8cd8d93a28764042a5558cc1c710b207690e11bd Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 13 Mar 2024 01:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E9=80=BB=E8=BE=91=E5=92=8C=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ica-rs/src/py/call.rs | 12 +++++------- ica-rs/src/py/mod.rs | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ica-rs/src/py/call.rs b/ica-rs/src/py/call.rs index 236a7f2..265d400 100644 --- a/ica-rs/src/py/call.rs +++ b/ica-rs/src/py/call.rs @@ -51,13 +51,11 @@ pub fn verify_plugins() { return; } let plugin_path = plugin_path.unwrap(); - for entry in std::fs::read_dir(plugin_path).unwrap() { - if let Ok(entry) = entry { - let path = entry.path(); - if let Some(ext) = path.extension() { - if ext == "py" && !PyStatus::verify_file(&path) { - need_reload_files.push(path); - } + for entry in std::fs::read_dir(plugin_path).unwrap().flatten() { + let path = entry.path(); + if let Some(ext) = path.extension() { + if ext == "py" && !PyStatus::verify_file(&path) { + need_reload_files.push(path); } } } diff --git a/ica-rs/src/py/mod.rs b/ica-rs/src/py/mod.rs index 24707f1..d7ccb0b 100644 --- a/ica-rs/src/py/mod.rs +++ b/ica-rs/src/py/mod.rs @@ -1,6 +1,7 @@ pub mod call; pub mod class; +use std::path::Path; use std::time::SystemTime; use std::{collections::HashMap, path::PathBuf}; @@ -222,7 +223,7 @@ pub fn get_change_time(path: &PathBuf) -> Option { path.metadata().ok()?.modified().ok() } -pub fn py_module_from_code(content: &str, path: &PathBuf) -> PyResult> { +pub fn py_module_from_code(content: &str, path: &Path) -> PyResult> { Python::with_gil(|py| -> PyResult> { let module: PyResult> = PyModule::from_code( py,