Skip to content

Commit e88083c

Browse files
Kenoclaude
andcommitted
Combine atomic file operations with exclusive locking
This commit combines atomic file operations with exclusive file locking to ensure safe concurrent access to configuration files. Changes: - Keep atomic file operations (write to temp file, then rename) - Add exclusive locking on config file during write operations - Lock is acquired in load_mut_config_db before reading - Lock is held throughout the read-modify-write cycle - Lock is automatically released when JuliaupConfigFile is dropped - Removes separate lock file mechanism The approach provides two layers of safety: 1. Exclusive locking ensures write operations are sequenced 2. Atomic rename ensures readers never see partial writes This eliminates race conditions while keeping the code simple. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4d981b4 commit e88083c

13 files changed

+67
-155
lines changed

src/bin/julialauncher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ fn run_app() -> Result<i32> {
316316
do_initial_setup(&paths.juliaupconfig)
317317
.with_context(|| "The Julia launcher failed to run the initial setup steps.")?;
318318

319-
let config_file = load_config_db(&paths, None)
319+
let config_file = load_config_db(&paths)
320320
.with_context(|| "The Julia launcher failed to load a configuration file.")?;
321321

322322
let versiondb_data = load_versions_db(&paths)

src/command_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn run_command_api(command: &str, paths: &GlobalPaths) -> Result<()> {
3939
other_versions: Vec::new(),
4040
};
4141

42-
let config_file = load_config_db(paths, None).with_context(|| {
42+
let config_file = load_config_db(paths).with_context(|| {
4343
"Failed to load configuration file while running the getconfig1 API command."
4444
})?;
4545

src/command_config_backgroundselfupdate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn run_command_config_backgroundselfupdate(
5757
}
5858
}
5959
None => {
60-
let config_file = load_config_db(paths, None)
60+
let config_file = load_config_db(paths)
6161
.with_context(|| "`config` command failed to load configuration data.")?;
6262

6363
if !quiet {

src/command_config_modifypath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn run_command_config_modifypath(
4141
}
4242
}
4343
None => {
44-
let config_file = load_config_db(paths, None)
44+
let config_file = load_config_db(paths)
4545
.with_context(|| "`config` command failed to load configuration data.")?;
4646

4747
if !quiet {

src/command_config_startupselfupdate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn run_command_config_startupselfupdate(
4747
}
4848
}
4949
None => {
50-
let config_file = load_config_db(paths, None)
50+
let config_file = load_config_db(paths)
5151
.with_context(|| "`config` command failed to load configuration data.")?;
5252

5353
if !quiet {

src/command_config_symlinks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn run_command_config_symlinks(
4343
}
4444
}
4545
None => {
46-
let config_file = load_config_db(paths, None)
46+
let config_file = load_config_db(paths)
4747
.with_context(|| "`config` command failed to load configuration data.")?;
4848

4949
if !quiet {

src/command_config_versionsdbupdate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn run_command_config_versionsdbupdate(
3838
}
3939
}
4040
None => {
41-
let config_file = load_config_db(paths, None)
41+
let config_file = load_config_db(paths)
4242
.with_context(|| "`config` command failed to load configuration data.")?;
4343

4444
if !quiet {

src/command_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use anyhow::{bail, Context, Result};
1010

1111
pub fn run_command_info(paths: &GlobalPaths) -> Result<()> {
1212
#[cfg(feature = "selfupdate")]
13-
let config_file = load_config_db(paths, None).with_context(|| {
13+
let config_file = load_config_db(paths).with_context(|| {
1414
"`run_command_update_version_db` command failed to load configuration db."
1515
})?;
1616

@@ -21,7 +21,7 @@ pub fn run_command_info(paths: &GlobalPaths) -> Result<()> {
2121
};
2222

2323
#[cfg(not(feature = "selfupdate"))]
24-
let _config_file = load_config_db(paths, None).with_context(|| {
24+
let _config_file = load_config_db(paths).with_context(|| {
2525
"`run_command_update_version_db` command failed to load configuration db."
2626
})?;
2727

src/command_override.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct OverrideRow {
2424
}
2525

2626
pub fn run_command_override_status(paths: &GlobalPaths) -> Result<()> {
27-
let config_file = load_config_db(paths, None)
27+
let config_file = load_config_db(paths)
2828
.with_context(|| "`override status` command failed to load configuration file.")?;
2929

3030
let rows_in_table: Vec<_> = config_file

src/command_status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct ChannelRow {
2626
}
2727

2828
pub fn run_command_status(paths: &GlobalPaths) -> Result<()> {
29-
let config_file = load_config_db(paths, None)
29+
let config_file = load_config_db(paths)
3030
.with_context(|| "`status` command failed to load configuration file.")?;
3131

3232
let versiondb_data =

0 commit comments

Comments
 (0)