WebDAV MKCOL: return 405 Exists if directory already exists (RFC 4918)
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled

P3 fix:
- create_dir: check vfs.exists() before creating
- Return FsError::Exists (405 Method Not Allowed) if path exists

Tests: 36 webdav tests pass
This commit is contained in:
Warren
2026-06-21 16:16:43 +08:00
parent 5000ba7c14
commit ab11983c1b

View File

@@ -645,6 +645,9 @@ impl DavFileSystem for VfsDavFs {
Ok(p) => p, Ok(p) => p,
Err(e) => return Box::pin(std::future::ready(Err(e))), Err(e) => return Box::pin(std::future::ready(Err(e))),
}; };
if self.vfs.exists(&full_path) {
return Box::pin(std::future::ready(Err(FsError::Exists)));
}
match self.vfs.create_dir_all(&full_path, 0o755) { match self.vfs.create_dir_all(&full_path, 0o755) {
Ok(_) => Box::pin(std::future::ready(Ok(()))), Ok(_) => Box::pin(std::future::ready(Ok(()))),
Err(_) => Box::pin(std::future::ready(Err(FsError::NotImplemented))), Err(_) => Box::pin(std::future::ready(Err(FsError::NotImplemented))),