Closed anlumo closed 4 years ago
Can you share your code? I've tested on Windows 10 but cannot reproduce this issue.
Here's a demo application: https://github.com/anlumo/zboxurls
Here's the output on my machine:
D:\zboxurls> cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
Running `target\debug\zboxurls.exe`
Opening URL: file:///D:/zboxurls/target/debug/test-fs
thread 'main' panicked at 'opening archive failed: Io(Os { code: 123, kind: Other, message: "The filename, directory name, or volume label syntax is incorrect." })', src\libcore\result.rs:1189:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\debug\zboxurls.exe` (exit code: 101)
Thanks @anlumo . The reason is that url generated by Url::from_file_path is not compatible with ZboxFS URI format, which requires an OS path after file://
.
For example, the required URI is like: file://C:/Users/foo bar/dir
, but the URI generated by Url::from_file_path
is like: file:///C:/Users/foo%20bar/dir
.
A quick solution might be converting the url back to path using url.to_file_path.
let url = Url::from_file_path(&path).unwrap();
RepoOpener::new()
.create_new(true)
.open(&format!("file://{}", url.to_file_path().unwrap().display()), "abcdef")
.expect("opening archive failed");
According to Wikipedia, this is not correct. It explicitly states that the third slash is required there.
However, I noticed that your API accepts file://D:\zboxurls\target\debug\test-fs
as the URL, which is horrible, but at least I can get it to work now…
The URI used in ZboxFS is not same as the standard URI or URL, it is different according to different storage. For file storage, it looks like an URL but actually not, it is just an identifier points to a path on OS. Anyway, I will update the doc to make it more clear.
I'm able to use the file storage on Windows 10 using urls like
file://../data/foo
, butfile://D:/data/foo
fails on theopen
call with the following error message:I'm generating the file URLs using Url::from_file_path, so the syntax should be ok. I can also paste this URL into Chrome and opens the folder view.