diff options
-rw-r--r-- | components/net/file_loader.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index df775775beb..73a1d81cc27 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -35,16 +35,23 @@ 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(); - 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); - progress_chan.send(Done(res)); + 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); + progress_chan.send(Done(res)); + } + Err(e) => { + progress_chan.send(Done(Err(e.desc.to_string()))); + } + } } - Err(e) => { - progress_chan.send(Done(Err(e.desc.to_string()))); + Err(_) => { + progress_chan.send(Done(Err(url.to_string()))); } - }; + } }); }; f |