fix: avoid duplicate capacity reservation for hardlinks

This commit is contained in:
2026-07-24 13:48:24 +00:00
parent 589fd4a41d
commit 748ca49837
8 changed files with 95 additions and 14 deletions
+27 -4
View File
@@ -69,14 +69,29 @@ class ClientJobHappyPathTests(unittest.TestCase):
with self.subTest(operation=operation), tempfile.TemporaryDirectory() as directory:
self._run_transfer(Path(directory), operation)
def _run_transfer(self, root: Path, operation: int):
def test_same_filesystem_source_stage_does_not_require_payload_space(self):
with tempfile.TemporaryDirectory() as directory:
self._run_transfer(
Path(directory),
job_pb2.JOB_OPERATION_ARCHIVE,
source_stage_free_bytes=1024 * 1024 * 1024 + 1024,
content=b"x" * 4096,
)
def _run_transfer(
self,
root: Path,
operation: int,
*,
source_stage_free_bytes: int | None = None,
content: bytes = b"archive-control-happy-path",
):
source_root = root / "source"
target_root = root / "target"
route_root = root / "route"
source_root.mkdir()
target_root.mkdir()
route_root.mkdir()
content = b"archive-control-happy-path"
(source_root / "fixture.bin").write_bytes(content)
info = {
b"length": len(content),
@@ -185,13 +200,21 @@ class ClientJobHappyPathTests(unittest.TestCase):
)
final = None
for executor, step in pipeline:
events = executor.execute(control_pb2.ExecuteStepCommand(
command = control_pb2.ExecuteStepCommand(
job_id=definition.job_id,
expected_job_revision=cursor_revision,
expected_last_event_sequence=cursor_sequence,
step=step,
attempt=1,
))
)
if executor is source and step == job_pb2.JOB_STEP_KIND_SOURCE_STAGE and source_stage_free_bytes is not None:
with patch(
"archive_clients.jobs.shutil.disk_usage",
return_value=Mock(free=source_stage_free_bytes),
):
events = executor.execute(command)
else:
events = executor.execute(command)
self.assertEqual(
[event.sequence for event in events],
list(range(