Skip the cache existence check when --no-download is set

Move the `fs.existsSync(indexPath)` check below the `--no-download`
early return: in that mode the check is unused (the read after
refreshIndex already validates existence), so it's wasted disk I/O.
This commit is contained in:
calixteman 2026-07-19 16:42:05 +02:00
parent c7dc7d7dd0
commit e6c7ab5425
No known key found for this signature in database
GPG Key ID: 0C5442631EE0691F

View File

@ -89,12 +89,12 @@ const etagPath = `${indexPath}.etag`;
// only when it has changed since the last run. When the network is unavailable
// a previously cached copy is reused if present.
async function refreshIndex() {
const hasCached = fs.existsSync(indexPath);
if (values["no-download"]) {
return; // Freshness check disabled; the read below validates existence.
}
const hasCached = fs.existsSync(indexPath);
// On any download failure, fall back to a previously cached copy when one
// exists; otherwise there's nothing to search, so fail.
const fallbackOrFail = reason => {