readers: Mutex<HashMap<PathBuf, (FileReader, SystemTime)>>,
}
-fn load_fs_file(f: impl AsRef<Path>) -> Result<Vec<PathBuf>> {
+fn load_fs_file(f: &PathBuf) -> Result<Vec<PathBuf>> {
use std::fs::read_to_string;
+ let mut dir = f.clone();
+ dir.pop();
+
read_to_string(f)
- .and_then(|s| Ok(s.lines().map(|l| PathBuf::from(l)).collect::<Vec<_>>()))
+ .and_then(|s| {
+ Ok(s.lines()
+ .map(|l| dir.clone().join(PathBuf::from(l)))
+ .collect::<Vec<_>>())
+ })
.map_err(|e| e.into())
}
pub fn new(fname: impl AsRef<Path>) -> Self {
Self {
fs_path: PathBuf::new().with_file_name(fname.as_ref()),
- last_reload: SystemTime::now() - Duration::new(2, 0),
+ last_reload: SystemTime::UNIX_EPOCH,
reload_interval: Duration::new(1, 0),
readers: Mutex::new(HashMap::new()),
}