@@ -22,8 +22,8 @@ pub struct WriteOptions {
22
22
pub block_size : Option < u64 > ,
23
23
/// Replication factor. Default is retrieved from the server.
24
24
pub replication : Option < u32 > ,
25
- /// Unix file permission, defaults to 0o755. This is the raw octal
26
- /// value represented in base 10.
25
+ /// Unix file permission, defaults to 0o644, which is "rw-r--r--" as a Unix permission.
26
+ /// This is the raw octal value represented in base 10.
27
27
pub permission : u32 ,
28
28
/// Whether to overwrite the file, defaults to false. If true and the
29
29
/// file does not exist, it will result in an error.
@@ -38,7 +38,7 @@ impl Default for WriteOptions {
38
38
Self {
39
39
block_size : None ,
40
40
replication : None ,
41
- permission : 0o755 ,
41
+ permission : 0o644 ,
42
42
overwrite : false ,
43
43
create_parent : true ,
44
44
}
@@ -445,6 +445,24 @@ impl Client {
445
445
. await ?;
446
446
Ok ( ( ) )
447
447
}
448
+
449
+ /// Sets permissions for a file. Permission should be an octal number reprenting the Unix style
450
+ /// permission.
451
+ ///
452
+ /// For example, to set permissions to rwxr-xr-x:
453
+ /// ```rust
454
+ /// # async fn func() {
455
+ /// # let client = hdfs_native::Client::new("localhost:9000").unwrap();
456
+ /// client.set_permission("/path", 0o755).await.unwrap();
457
+ /// }
458
+ /// ```
459
+ pub async fn set_permission ( & self , path : & str , permission : u32 ) -> Result < ( ) > {
460
+ let ( link, resolved_path) = self . mount_table . resolve ( path) ;
461
+ link. protocol
462
+ . set_permission ( & resolved_path, permission)
463
+ . await ?;
464
+ Ok ( ( ) )
465
+ }
448
466
}
449
467
450
468
impl Default for Client {
0 commit comments