Skip to content

Commit

Permalink
Auto merge of #13304 - frewsxcv:ownership, r=jdm
Browse files Browse the repository at this point in the history
Don't require `PathBuf` ownership if we don't need it.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13304)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Sep 17, 2016
2 parents 2fb4dd9 + 3aa2ec6 commit 6ac9dfd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions components/net/file_loader.rs
Expand Up @@ -14,7 +14,7 @@ use std::borrow::ToOwned;
use std::error::Error;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::path::Path;
use std::sync::Arc;
use url::Url;
use util::thread::spawn_named;
Expand Down Expand Up @@ -68,11 +68,11 @@ fn read_all(reader: &mut File, progress_chan: &ProgressSender, cancel_listener:
Ok(LoadResult::Cancelled)
}

fn get_progress_chan(load_data: LoadData, file_path: PathBuf,
fn get_progress_chan(load_data: LoadData, file_path: &Path,
senders: LoadConsumer, classifier: Arc<MimeClassifier>, buf: &[u8])
-> Result<ProgressSender, ()> {
let mut metadata = Metadata::default(load_data.url);
let mime_type = guess_mime_type(file_path.as_path());
let mime_type = guess_mime_type(file_path);
metadata.set_content_type(Some(&mime_type));
return start_sending_sniffed_opt(senders, metadata, classifier, buf, load_data.context);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn factory(load_data: LoadData,
};

if cancel_listener.is_cancelled() {
if let Ok(progress_chan) = get_progress_chan(load_data, file_path,
if let Ok(progress_chan) = get_progress_chan(load_data, &file_path,
senders, classifier, &[]) {
let _ = progress_chan.send(Done(Err(NetworkError::LoadCancelled)));
}
Expand All @@ -114,7 +114,7 @@ pub fn factory(load_data: LoadData,

match read_block(reader) {
Ok(ReadStatus::Partial(buf)) => {
let progress_chan = get_progress_chan(load_data, file_path,
let progress_chan = get_progress_chan(load_data, &file_path,
senders, classifier, &buf).ok().unwrap();
progress_chan.send(Payload(buf)).unwrap();
let read_result = read_all(reader, &progress_chan, &cancel_listener);
Expand All @@ -126,7 +126,7 @@ pub fn factory(load_data: LoadData,
}
}
Ok(ReadStatus::EOF) => {
if let Ok(chan) = get_progress_chan(load_data, file_path,
if let Ok(chan) = get_progress_chan(load_data, &file_path,
senders, classifier, &[]) {
let _ = chan.send(Done(Ok(())));
}
Expand Down

0 comments on commit 6ac9dfd

Please sign in to comment.