mirror of
https://github.com/YGGverse/btracker-fs.git
synced 2026-03-31 17:15:28 +00:00
rename to path method filepath, additionally validate the given location is file
This commit is contained in:
parent
c2fed39c22
commit
bf20fce978
1 changed files with 3 additions and 3 deletions
|
|
@ -92,15 +92,15 @@ impl Public {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return canonical absolute path
|
/// Return canonical absolute path to file
|
||||||
///
|
///
|
||||||
/// * `None` if the given URI does not exist or has denied location
|
/// * `None` if the given URI does not exist or has denied location
|
||||||
pub fn path(&self, relative: &str) -> Option<PathBuf> {
|
pub fn filepath(&self, relative: &str) -> Option<PathBuf> {
|
||||||
let mut p = PathBuf::from(&self.root);
|
let mut p = PathBuf::from(&self.root);
|
||||||
p.push(&relative);
|
p.push(&relative);
|
||||||
|
|
||||||
let c = p.canonicalize().ok()?;
|
let c = p.canonicalize().ok()?;
|
||||||
if c.starts_with(&self.root) && c.exists() {
|
if c.starts_with(&self.root) && c.exists() && c.is_file() {
|
||||||
Some(c)
|
Some(c)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue