prabirshrestha opened a new issue, #3009:
URL: https://github.com/apache/incubator-opendal/issues/3009
I'm trying opendal with synology nas using the following code.
<details>
<summary>main.rs</summary>
```rust
use futures_lite::StreamExt;
use opendal::{Metakey, Operator};
#[tokio::main]
async fn main() {
let mut builder = opendal::services::Webdav::default();
builder
.endpoint("https://someaddress")
.username("username")
.password("password")
.root("/");
let op = Operator::new(builder).unwrap().finish();
let mut ds = op.list("/").await.unwrap();
while let Some(de) = ds.try_next().await.unwrap() {
dbg!(&de);
let metadata = op
.metadata(
&de,
Metakey::LastModified
| Metakey::Mode
| Metakey::ContentType
| Metakey::ContentLength,
)
.await
.unwrap();
dbg!(&metadata);
}
}
```
</details>
<details>
<summary>Cargo.toml</summary>
```yaml
[package]
name = "opendal-bug"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at
https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
futures-lite = "1.13.0"
opendal = "0.39.0"
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }
```
</details>
This works until we get a directory that has spaces and it seems to double
encode when calling metadata.
<details>
<summary>PROPFIND for listing directory returns encoded href already. Notice
the %20</summary>
```xml
<D:response
xmlns:lp1="DAV:"
xmlns:lp2="http://apache.org/dav/props/">
<D:href>/Time%20Machine%20Backup</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype>
<D:collection/>
</lp1:resourcetype>
<lp1:creationdate>2021-06-02T05:09:18Z</lp1:creationdate>
<lp1:getlastmodified>Wed, 21 Dec 2022 18:49:34
GMT</lp1:getlastmodified>
<lp1:getetag>"4a4-5f05b037e3f85"</lp1:getetag>
<D:supportedlock>
<D:lockentry>
<D:lockscope>
<D:exclusive/>
</D:lockscope>
<D:locktype>
<D:write/>
</D:locktype>
</D:lockentry>
<D:lockentry>
<D:lockscope>
<D:shared/>
</D:lockscope>
<D:locktype>
<D:write/>
</D:locktype>
</D:lockentry>
</D:supportedlock>
<D:lockdiscovery/>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
```
</details>
<details>
<summary>Log for directory entry from opendal</summary>
```rust
[src/main.rs:19] &de = Entry {
path: "Time%20Machine%20Backup",
metadata: Some(
Metadata {
bit: FlagSet(Mode | ContentType | Etag | LastModified),
mode: FILE,
cache_control: None,
content_disposition: None,
content_length: None,
content_md5: None,
content_range: None,
content_type: Some(
"httpd/unix-directory",
),
etag: Some(
"\"4a4-5f05b037e3f85\"",
),
last_modified: Some(
2022-12-21T18:49:34Z,
),
version: None,
},
),
}
```
</details>
<details>
<summary>It fails in metadata due to double encoding</summary>
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
Unexpected (permanent) at stat => <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method PROPFIND is not allowed for this URL.</p>
</body></html>
Context:
uri: https://someaddress//Time%2520Machine%2520Backup
response: Parts { status: 405, version: HTTP/1.1, headers: {"date":
"Tue, 05 Sep 2023 08:08:16 GMT", "server": "Apache", "allow":
"HEAD,GET,POST,OPTIONS", "content-length": "225", "content-type": "text/html;
charset=iso-8859-1"} }
service: webdav
path: Time%20Machine%20Backup
', src/main.rs:29:14
```
</details>
This works in Synology as well as owncloud.
```rust
let stat = op.stat("/Time Machine Backup/").await.unwrap();
```
This fails in Synology NAS because internally it is making request to
`/Time%2520Machine%2520Backup/` which is double encoded. It however works in
Owncloud.
```rust
let stat = op.stat("/Time%20Machine%20Backup/").await.unwrap();
```
I'm using demo.ownlcoud.com to test it out. you can go to demo.owncloud.com,
login and create a directory called `Time Machine Backup` and use the following
settings.
```
builder
.endpoint("https://demo.owncloud.com/remote.php/dav/files/demo/")
.username("demo")
.password("demo")
.root("/");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]