Repository navigation
Conversation
Checking that pubspecPath exists before skipping cached packages ensures that missing cached dependencies trigger a re-resolution instead of crashing in Package.load.
Also replace the stale reference to the removed `_arePackagesAvailable` in `isPackageConfigUpToDate` with a description of why that check is still needed next to the one in the main loop.
`isResolutionUpToDate` now triggers a resolution when a cached package has no `pubspec.yaml`, but `HostedSource.downloadToSystemCache` only redownloaded a package when its directory was missing. With the directory present and the `pubspec.yaml` gone the implicit `pub get` therefore left the entry alone and `Package.load` failed with the same error as before, on every invocation. Treat such an entry as damaged and redownload it, like a wrong content hash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
Entrypoint.isResolutionUpToDate, check thatpubspec.yamlexists before skipping cached packages.Previously, packages within
cache.rootDirwere skipped before verifying file existence withtryStatFile. On the fast path (all timestamps in order) nothing else looked at those packages, so if a cached package had been deleted from the pub cache,isResolutionUpToDatestill considered the resolution up-to-date, and commands such asdart pub deps --jsonfailed later inPackage.loadwithCould not find a file named "pubspec.yaml". (The slow path already caught this inisPackageConfigUpToDate.) Cached packages still skip the timestamp comparison, since their mtimes say nothing about the current resolution.The resulting implicit
pub getonly redownloads a hosted package when its directory is missing. To make the repair work when the directory is present butpubspec.yamlinside it is gone,HostedSource.downloadToSystemCachenow treats such an entry as damaged and redownloads it (with a warning), mirroring the existing handling of a wrong content hash.Cost: one extra
statper cached package on every up-to-date check. Measured on a 121-dependency project: +1.1 ms per invocation with a warm filesystem cache (≈10 µs/package); with a cold dentry cache on a network-backed disk (cloud VM, CI) ≈0.3 ms/package, i.e. tens of ms once for a few hundred packages, after which the cache is warm.Fixes #4559.