sapling/eden/scm/lib/util/Cargo.toml
Zeyi (Rice) Fan 3374b99f28 util: ensure correct permission is set when creating directories
Summary:
When creates directories sometime we want to make sure other users within the same group have the write access to it to enable data sharing. Previously we rely on setting umask for the entire process to make sure the newly created directories have the correct permission bit. This is kind fragile and error-prone when running in a multi-thread environment.

This diff introduces an internal function `create_dir_with_mode` to create directory with specified permission mode. It first creates a temporary directory within the parent of the directory being created, setting up the correct permission bit, then attempts to rename the temporary directory to the desired name. This ensures that we never leave a directory without the correct permission in the place we need and without changing umask for the process.

Reviewed By: xavierd

Differential Revision: D21188903

fbshipit-source-id: 381bff7d3aaca097b9d50150e86cbbf70a90a0a5
2020-04-24 17:17:05 -07:00

12 lines
162 B
TOML

[package]
name = "util"
version = "0.1.0"
edition = "2018"
[dependencies]
anyhow = "1.0.20"
dirs = "2.0.2"
libc = "0.2"
shellexpand = "1.0.0"
tempfile = "3.0.4"