summaryrefslogtreecommitdiff
path: root/cli/ops
diff options
context:
space:
mode:
authordubiousjim <dubiousjim@gmail.com>2020-07-06 07:15:13 -0400
committerGitHub <noreply@github.com>2020-07-06 13:15:13 +0200
commit6b78729ba8c21f6b3ba5a4621fc363d8772e177f (patch)
tree7ac29fd456c6a0e643bdd804d026d96ac8678199 /cli/ops
parent79610378d3001757b7664a0cefa8fc99125f5a18 (diff)
feat: Deno.chown() make uid, gid args optional (#4612)
Diffstat (limited to 'cli/ops')
-rw-r--r--cli/ops/fs.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs
index 0d5d0c9bf..66487c41b 100644
--- a/cli/ops/fs.rs
+++ b/cli/ops/fs.rs
@@ -475,8 +475,8 @@ fn op_chmod(
struct ChownArgs {
promise_id: Option<u64>,
path: String,
- uid: u32,
- gid: u32,
+ uid: Option<u32>,
+ gid: Option<u32>,
}
fn op_chown(
@@ -491,20 +491,18 @@ fn op_chown(
let is_sync = args.promise_id.is_none();
blocking_json(is_sync, move || {
- debug!("op_chown {} {} {}", path.display(), args.uid, args.gid);
+ debug!("op_chown {} {:?} {:?}", path.display(), args.uid, args.gid,);
#[cfg(unix)]
{
use nix::unistd::{chown, Gid, Uid};
- let nix_uid = Uid::from_raw(args.uid);
- let nix_gid = Gid::from_raw(args.gid);
- chown(&path, Option::Some(nix_uid), Option::Some(nix_gid))?;
+ let nix_uid = args.uid.map(Uid::from_raw);
+ let nix_gid = args.gid.map(Gid::from_raw);
+ chown(&path, nix_uid, nix_gid)?;
Ok(json!({}))
}
// TODO Implement chown for Windows
#[cfg(not(unix))]
{
- // Still check file/dir exists on Windows
- let _metadata = std::fs::metadata(&path)?;
Err(OpError::not_implemented())
}
})