mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Merge pull request #3284 from glennw/file-loader-fix
Return error when unable to create a file path from url.
This commit is contained in:
commit
68dcc67d98
1 changed files with 15 additions and 8 deletions
|
@ -35,7 +35,9 @@ pub fn factory() -> LoaderTask {
|
|||
assert!("file" == url.scheme.as_slice());
|
||||
let progress_chan = start_sending(start_chan, Metadata::default(url.clone()));
|
||||
spawn_named("file_loader", proc() {
|
||||
let file_path: Path = url.to_file_path().unwrap();
|
||||
let file_path: Result<Path, ()> = url.to_file_path();
|
||||
match file_path {
|
||||
Ok(file_path) => {
|
||||
match File::open_mode(&Path::new(file_path), io::Open, io::Read) {
|
||||
Ok(ref mut reader) => {
|
||||
let res = read_all(reader as &mut io::Stream, &progress_chan);
|
||||
|
@ -44,7 +46,12 @@ pub fn factory() -> LoaderTask {
|
|||
Err(e) => {
|
||||
progress_chan.send(Done(Err(e.desc.to_string())));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
progress_chan.send(Done(Err(url.to_string())));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
f
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue