This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 769e6257 Only extract archives added before quarantining once
769e6257 is described below

commit 769e6257552f215df0705e4574d7f2095e08a4f9
Author: Sean B. Palmer <[email protected]>
AuthorDate: Sun Mar 8 18:38:19 2026 +0000

    Only extract archives added before quarantining once
---
 atr/tasks/quarantine.py                | 12 ++++++++++++
 tests/unit/test_quarantine_backfill.py | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/atr/tasks/quarantine.py b/atr/tasks/quarantine.py
index 9ce64daa..81beef4f 100644
--- a/atr/tasks/quarantine.py
+++ b/atr/tasks/quarantine.py
@@ -58,8 +58,14 @@ class QuarantineValidate(schema.Strict):
 
 
 def backfill_archive_cache() -> list[tuple[str, pathlib.Path, float]]:
+    done_file = _backfill_done_file()
+    if done_file.exists():
+        return []
+
     unfinished_dir = paths.get_unfinished_dir()
     if not unfinished_dir.is_dir():
+        done_file.parent.mkdir(parents=True, exist_ok=True)
+        done_file.touch()
         return []
 
     cache_archives_dir = paths.get_cache_archives_dir()
@@ -89,6 +95,8 @@ def backfill_archive_cache() -> list[tuple[str, pathlib.Path, 
float]]:
                     results_list,
                 )
 
+    done_file.parent.mkdir(parents=True, exist_ok=True)
+    done_file.touch()
     return results_list
 
 
@@ -134,6 +142,10 @@ async def validate(args: QuarantineValidate) -> 
results.Results | None:
     return None
 
 
+def _backfill_done_file() -> pathlib.Path:
+    return paths.get_cache_archives_dir().parent / "archive-backfill.done"
+
+
 def _backfill_extract_archive(
     archive_path: pathlib.Path,
     cache_dir: pathlib.Path,
diff --git a/tests/unit/test_quarantine_backfill.py 
b/tests/unit/test_quarantine_backfill.py
index 89f1b5b7..3f6c125d 100644
--- a/tests/unit/test_quarantine_backfill.py
+++ b/tests/unit/test_quarantine_backfill.py
@@ -91,6 +91,7 @@ def test_backfill_empty_unfinished_dir(monkeypatch: 
pytest.MonkeyPatch, tmp_path
     result = quarantine.backfill_archive_cache()
 
     assert result == []
+    assert (tmp_path / "cache" / "archive-backfill.done").is_file()
 
 
 def test_backfill_extracts_same_content_into_different_namespaces(
@@ -135,6 +136,7 @@ def test_backfill_extracts_uncached_archive(monkeypatch: 
pytest.MonkeyPatch, tmp
     assert result_cache_dir.is_dir()
     assert (result_cache_dir / "README.txt").read_text() == "Hello"
     assert duration >= 0
+    assert (tmp_path / "cache" / "archive-backfill.done").is_file()
 
 
 def test_backfill_skips_non_archive_files(monkeypatch: pytest.MonkeyPatch, 
tmp_path: pathlib.Path) -> None:
@@ -151,6 +153,23 @@ def test_backfill_skips_non_archive_files(monkeypatch: 
pytest.MonkeyPatch, tmp_p
     assert result == []
 
 
+def test_backfill_skips_scan_when_done_file_exists(monkeypatch: 
pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None:
+    unfinished_dir, cache_dir = _setup_dirs(tmp_path)
+    _patch_paths(monkeypatch, tmp_path, unfinished_dir, cache_dir)
+
+    done_file = tmp_path / "cache" / "archive-backfill.done"
+    done_file.touch()
+
+    def fail_if_called(*args, **kwargs) -> None:
+        raise AssertionError("backfill scan should be skipped when the done 
file exists")
+
+    monkeypatch.setattr(quarantine, "_backfill_revision", fail_if_called)
+
+    result = quarantine.backfill_archive_cache()
+
+    assert result == []
+
+
 def _create_tar_gz(path: pathlib.Path) -> None:
     buf = io.BytesIO()
     with tarfile.open(fileobj=buf, mode="w:gz") as tar:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to