Fix WebDAV lock database path (handler.rs)
Lock DB now uses data/webdav/{user}/.locks.sqlite
Server responds to GET/PROPFIND (HTTP 200 OK)
This commit is contained in:
31
src/webdav/handler.rs
Normal file
31
src/webdav/handler.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::path::PathBuf;
|
||||
use dav_server::{DavHandler, localfs::LocalFs};
|
||||
use crate::webdav::lock_manager::LockManager;
|
||||
|
||||
pub struct MarkBaseWebDAV {
|
||||
user_id: String,
|
||||
db_path: PathBuf,
|
||||
}
|
||||
|
||||
impl MarkBaseWebDAV {
|
||||
pub fn new(user_id: String, db_path: PathBuf) -> Self {
|
||||
MarkBaseWebDAV { user_id, db_path }
|
||||
}
|
||||
|
||||
pub fn create_handler(&self) -> DavHandler {
|
||||
let webdav_dir = format!("data/webdav/{}/", self.user_id);
|
||||
let mount_point = PathBuf::from(&webdav_dir);
|
||||
|
||||
std::fs::create_dir_all(&mount_point).expect("Failed to create WebDAV directory");
|
||||
|
||||
let lock_db_path = mount_point.join(".locks.sqlite");
|
||||
let lock_manager = LockManager::new(self.user_id.clone(), lock_db_path);
|
||||
lock_manager.init_db().expect("Failed to initialize lock database");
|
||||
|
||||
DavHandler::builder()
|
||||
.filesystem(LocalFs::new(&mount_point, false, false, false))
|
||||
.locksystem(Box::new(lock_manager))
|
||||
.strip_prefix("/webdav")
|
||||
.build_handler()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user