Follow the filesystem contract that dropped resource ids and publishing

This commit is contained in:
Danny Kim
2026-09-25 12:40:54 +09:00
parent bca12b4c2e
commit df3635569a
3 changed files with 22 additions and 50 deletions
+11 -23
View File
@@ -52,13 +52,10 @@ fn transport(error: host::HostError) -> ErrorCode {
}
}
/// The path a locator names. This provider addresses by path only, because
/// WebDAV has no identity separate from the URL.
fn route(target: &Locator) -> Result<String, ErrorCode> {
match target {
Locator::Path(path) => Ok(path.clone()),
Locator::Id(_) => Err(ErrorCode::InvalidInput),
}
/// The path a locator names, the only way the contract addresses a resource.
fn route(target: &Locator) -> String {
let Locator::Path(path) = target;
path.clone()
}
fn session<T>(
@@ -143,7 +140,6 @@ fn info_of(found: &dav::Found) -> FileInfo {
},
size: found.length,
revision: found.etag.clone(),
id: None,
}
}
@@ -194,7 +190,6 @@ impl GuestWriter for DavWriter {
kind: EntryKind::File,
size: 0,
revision,
id: None,
}))
}
}
@@ -236,8 +231,6 @@ impl Guest for Webdav {
// will refuse the header rather than silently overwrite.
conditional_write: true,
watch: false,
staged_write: false,
publishable: false,
virtual_directories: false,
})
}
@@ -247,7 +240,7 @@ impl Guest for Webdav {
}
fn stat(target: Locator) -> Result<FileInfo, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
let body = exchange(
host::Method::Propfind,
&path,
@@ -266,7 +259,7 @@ impl Guest for Webdav {
cursor: Option<String>,
limit: u32,
) -> Result<ListPage, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
let start: usize = match cursor {
Some(value) => value.parse().map_err(|_| ErrorCode::InvalidInput)?,
None => 0,
@@ -296,7 +289,7 @@ impl Guest for Webdav {
}
fn open_read(target: Locator, offset: u64) -> Result<Reader, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
let call = begin(
host::Method::Get,
&path,
@@ -320,7 +313,7 @@ impl Guest for Webdav {
condition: WriteCondition,
_size_hint: Option<u64>,
) -> Result<Writer, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
let guard = match condition {
WriteCondition::CreateOnly => Some(host::Header {
name: "if-none-match".to_owned(),
@@ -340,13 +333,12 @@ impl Guest for Webdav {
}
fn mkdir(target: Locator) -> Result<FileInfo, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
exchange(host::Method::Mkcol, &path, Vec::new(), &[])?;
Ok(FileInfo {
kind: EntryKind::Directory,
size: 0,
revision: None,
id: None,
})
}
@@ -354,7 +346,7 @@ impl Guest for Webdav {
target: Locator,
destination: String,
) -> Result<FileInfo, ErrorCode> {
let path = route(&target)?;
let path = route(&target);
let to = session(|session| Ok(dav::url(&session.root, &destination)))?;
exchange(
host::Method::Move,
@@ -377,7 +369,7 @@ impl Guest for Webdav {
}
fn remove(target: Locator) -> Result<(), ErrorCode> {
let path = route(&target)?;
let path = route(&target);
exchange(host::Method::Delete, &path, Vec::new(), &[])?;
Ok(())
}
@@ -385,10 +377,6 @@ impl Guest for Webdav {
fn poll(_cursor: Option<String>) -> Result<ChangePage, ErrorCode> {
Err(ErrorCode::Unsupported)
}
fn publish() -> Result<Option<String>, ErrorCode> {
Err(ErrorCode::Unsupported)
}
}
sdk::export!(Webdav with_types_in sdk);