diff options
Diffstat (limited to 'src/database/file')
-rw-r--r-- | src/database/file/mod.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index f6715e1..ba8201f 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -197,15 +197,7 @@ fn modify_post(post: &serde_json::Value, update: MicropubUpdate) -> Result<serde /// A backend using a folder with JSON files as a backing store. /// Uses symbolic links to represent a many-to-one mapping of URLs to a post. pub struct FileStorage { - root_dir: PathBuf, -} - -impl FileStorage { - /// Create a new storage wrapping a folder specified by root_dir. - pub async fn new(root_dir: PathBuf) -> Result<Self> { - // TODO check if the dir is writable - Ok(Self { root_dir }) - } + pub(super) root_dir: PathBuf, } async fn hydrate_author<S: Storage>( @@ -255,6 +247,10 @@ async fn hydrate_author<S: Storage>( #[async_trait] impl Storage for FileStorage { + async fn new(url: &'_ url::Url) -> Result<Self> { + // TODO: sanity check + Ok(Self { root_dir: PathBuf::from(url.path()) }) + } #[tracing::instrument(skip(self))] async fn categories(&self, url: &str) -> Result<Vec<String>> { // This requires an expensive scan through the entire |