summaryrefslogtreecommitdiffstats
path: root/src/filestore/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/filestore/path.rs')
-rw-r--r--src/filestore/path.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/filestore/path.rs b/src/filestore/path.rs
index 25ffbd9..134c132 100644
--- a/src/filestore/path.rs
+++ b/src/filestore/path.rs
@@ -11,9 +11,13 @@ use anyhow::Context;
pub struct StoreRoot(PathBuf);
impl StoreRoot {
- pub (in crate::filestore) fn new(root: PathBuf) -> Result<Self> {
+ pub fn new(root: PathBuf) -> Result<Self> {
if root.is_absolute() {
- Ok(StoreRoot(root))
+ if root.is_dir() {
+ Ok(StoreRoot(root))
+ } else {
+ Err(anyhow!("StoreRoot path does not point to directory: {}", root.display()))
+ }
} else {
Err(anyhow!("StoreRoot path is not absolute: {}", root.display()))
}
@@ -37,6 +41,10 @@ impl StoreRoot {
self.0.join(subpath).is_dir()
}
+ pub (in crate::filestore) fn as_path(&self) -> &Path {
+ self.0.as_ref()
+ }
+
pub fn display(&self) -> std::path::Display {
self.0.display()
}