diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-09-11 08:59:04 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-09-11 08:59:04 -0400 |
commit | 68dcc67d9809477927e2c47dd5bd77d5f450e052 (patch) | |
tree | 1c1b1e0002b777b0115a87abc6f89ab907252348 | |
parent | 1124430eeae73a6329926ad715cdf451be02c4d8 (diff) | |
parent | 627359e9e4f3c3958da903d7eb1a165b33b6f408 (diff) | |
download | servo-68dcc67d9809477927e2c47dd5bd77d5f450e052.tar.gz servo-68dcc67d9809477927e2c47dd5bd77d5f450e052.zip |
Merge pull request #3284 from glennw/file-loader-fix
Return error when unable to create a file path from url.
-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 |