fix: report missing assets when no cache exists

This commit is contained in:
Abdessamad Derraz committed 2026-10-16 22:09:39 +02:00
1 parent 8892432866
commit 61f49b7ac0
2 files changed
+29 -4

No files matched your search

+7 -4
View File
@@ -54,11 +54,14 @@ def index_cache(cache_dir: str) -> dict[str, str]:
def restore(
cache_dir: str, db_path: str, gitignore: str
) -> tuple[int, list[str]]:
if not os.path.isdir(cache_dir):
print(f"No cache at {cache_dir}, nothing to restore")
return 0, []
ignored = gitignored_paths(gitignore)
index = index_cache(cache_dir)
# No cache is not nothing to do: the paths it would have supplied are
# still missing, and the check below is the one that must say so.
if os.path.isdir(cache_dir):
index = index_cache(cache_dir)
else:
print(f"No cache at {cache_dir}")
index = {}
db = load_database(db_path)
restored = 0
unsatisfied: list[str] = []
+22
View File
@@ -1414,6 +1414,28 @@ class CheckoutCompletenessRegressions(unittest.TestCase):
finally:
os.chdir(cwd)
def test_restore_without_a_cache_names_what_is_missing(self):
"""A job that skipped `mkdir .cache/large` exited 0 with every
gitignored file absent: the early return ran before the check."""
from scripts.restore_large_files import restore
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
root = Path(directory)
(root / ".gitignore").write_text("bios/big.bin\n", encoding="utf-8")
(root / "database.json").write_text(
json.dumps({"files": {"a" * 40: {"path": "bios/big.bin"}}}),
encoding="utf-8",
)
cwd = os.getcwd()
os.chdir(root)
try:
self.assertEqual(
restore("no-cache", "database.json", ".gitignore"),
(0, ["bios/big.bin"]),
)
finally:
os.chdir(cwd)
class EveryManifestEntryIsFetchable(unittest.TestCase):
"""An install manifest may not list a file the installer cannot get.