Skip to content

Commit 35226fc

Browse files
committed
fix: create a more local lock when creating writable fixtures.
Previously, the lock location would block all writers from executing a fixture even though they wouldn't step on each others feet. Now, a script destination is used to assure locks are created close to the destination when creating writable fixtures, typically removing the need for multiple writers to wait on each other unnecessarily.
1 parent a33790e commit 35226fc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: tests/tools/src/lib.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,18 @@ fn scripted_fixture_read_only_with_args_inner(
509509
|d| (true, d.to_owned()),
510510
);
511511

512-
let _marker = gix_lock::Marker::acquire_to_hold_resource(
513-
script_basename,
514-
gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)),
515-
None,
516-
)?;
512+
// We may that destination_dir is already unique (i.e. temp-dir) - thus there is no need for a lock,
513+
// and we can execute scripts in parallel.
514+
let _marker = destination_dir
515+
.is_none()
516+
.then(|| {
517+
gix_lock::Marker::acquire_to_hold_resource(
518+
script_basename,
519+
gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)),
520+
None,
521+
)
522+
})
523+
.transpose()?;
517524
let failure_marker = script_result_directory.join("_invalid_state_due_to_script_failure_");
518525
if force_run || !script_result_directory.is_dir() || failure_marker.is_file() {
519526
if failure_marker.is_file() {

0 commit comments

Comments
 (0)