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:
Josh Matthews 2014-09-11 08:59:04 -04:00
commit 68dcc67d98

View file

@ -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