0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

Small handers.rs cleanup (#735)

This commit is contained in:
JaePil Jung 2018-09-13 04:17:17 +09:00 committed by Ryan Dahl
parent 41c70b154f
commit 5bea62ac32

View file

@ -420,7 +420,7 @@ fn handle_make_temp_dir(d: *const DenoC, base: &msg::Base) -> Box<Op> {
let deno = from_c(d); let deno = from_c(d);
if !deno.flags.allow_write { if !deno.flags.allow_write {
return Box::new(futures::future::err(permission_denied())); return odd_future(permission_denied());
} }
// TODO Use blocking() here. // TODO Use blocking() here.
Box::new(futures::future::result(|| -> OpResult { Box::new(futures::future::result(|| -> OpResult {
@ -590,16 +590,15 @@ fn handle_write_file(d: *const DenoC, base: &msg::Base) -> Box<Op> {
let filename = String::from(msg.filename().unwrap()); let filename = String::from(msg.filename().unwrap());
let data = msg.data().unwrap(); let data = msg.data().unwrap();
let perm = msg.perm(); let perm = msg.perm();
let deno = from_c(d);
debug!("handle_write_file {}", filename); let deno = from_c(d);
if !deno.flags.allow_write {
return odd_future(permission_denied());
}
Box::new(futures::future::result(|| -> OpResult { Box::new(futures::future::result(|| -> OpResult {
if !deno.flags.allow_write { debug!("handle_write_file {}", filename);
Err(permission_denied()) deno_fs::write_file(Path::new(&filename), data, perm)?;
} else { Ok(None)
deno_fs::write_file(Path::new(&filename), data, perm)?;
Ok(None)
}
}())) }()))
} }
@ -664,7 +663,7 @@ fn handle_rename(d: *const DenoC, base: &msg::Base) -> Box<Op> {
let deno = from_c(d); let deno = from_c(d);
if !deno.flags.allow_write { if !deno.flags.allow_write {
return odd_future(permission_denied()); return odd_future(permission_denied());
} };
let msg = base.msg_as_rename().unwrap(); let msg = base.msg_as_rename().unwrap();
let oldpath = String::from(msg.oldpath().unwrap()); let oldpath = String::from(msg.oldpath().unwrap());
let newpath = String::from(msg.newpath().unwrap()); let newpath = String::from(msg.newpath().unwrap());