Skip to content

Commit a53186d

Browse files
jolissSchniz
andauthored
Add random number to multishell symlinks (#1536)
* Add random number to multishell symlinks This protects against collisions when multiple shells are started in parallel inside Bubblewrap sandboxes, as each shell will have the same timestamp and the same low PID (e.g. 2), since Bubblewrap sandboxes have isolated PID spaces. * Add a changeset --------- Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
1 parent b24c183 commit a53186d

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

.changeset/warm-apes-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fnm": patch
3+
---
4+
5+
Add random number to multishell symlinks to avoid clashing

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ etcetera = "0.8.0"
2020
colored = "2.1.0"
2121
zip = "2.1.0"
2222
tempfile = "3.10.1"
23+
fastrand = "2.1.1"
2324
indoc = "2.0.5"
2425
log = "0.4.21"
2526
env_logger = "0.11.3"

src/commands/env.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ pub struct Env {
3030

3131
fn generate_symlink_path() -> String {
3232
format!(
33-
"{}_{}",
33+
"{}_{}_{:010}",
3434
std::process::id(),
3535
chrono::Utc::now().timestamp_millis(),
36+
fastrand::u64(..10_000_000_000),
3637
)
3738
}
3839

0 commit comments

Comments
 (0)