Cache remote refs when downloading, refactor cachedownloader#457
Merged
Conversation
Separate the existing singular downloader into two distinct objects:
the bound and unbound variants. An unbound downloader implements the
core logic, almost to completion. A bound downloader *contains* an
unbound one and adds a known file target (remote and local names to
use).
The two are tied together via a single method:
CacheDownloader.bind(URI, name) -> BoundCacheDownloader
The result allows for a CacheDownloader to be built and then bound
multiple times.
Several refinements are needed in the CacheDownloader to support this. Primarily, support for sibling directories to the `downloads` dir, in the cache dir. This allows the ref resolver to pass in `"refs"` as a directory name. As a related change in the course of this work, HTTP retries are expanded in scope to also cover connection errors and timeouts. Additionally, `disable_cache` gets passed down from the CLI through to the ref resolution layer. Tests are enhanced to better explore CacheDownloader behaviors, but not to test the usage in ref resolution.
Rather than pure MD5, capture the extension used. This allows for `.json5` and `.yaml` files, which indicate filetype to parsing.
With any non-`.json` suffix, e.g., `.yaml`, we need the cache to preserve extensions in order to be certain that the cache loader will choose the same parser when loading the cached ref as the one it used when the ref was remote. The `.yaml` ref + cache population trickery allows us to test this codepath in an acceptance test.
Add new fixtures which expose nicer interfaces for interacting with the download caches. These are split into two variants -- one for `refs/` and one for `downloads/` -- for the relevant functions. The new fixtures cover getting the relevant cache dir as a path, getting the expected cache location for a URI as a path (without creating it), and injecting some specific file contents into said path, including creation of the parent dir structure. These new fixtures are then applied in as many locations as possible for a small but valuable reduction in test complexity and tight coupling between specific tests and the implementation.
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.
Resolves #452.