mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
feat(unstable): single checksum per JSR package in the lockfile (#22421)
This changes the lockfile to not store JSR specifiers in the "remote" section. Instead a single JSR integrity is stored per package in the lockfile, which is a hash of the version's `x.x.x_meta.json` file, which contains hashes for every file in the package. The hashes in this file are then compared against when loading. Additionally, when using `{ "vendor": true }` in a deno.json, the files can be modified without causing lockfile errors—the checksum is only checked when copying into the vendor folder and not afterwards (eventually we should add this behaviour for non-jsr specifiers as well). As part of this change, the `vendor` folder creation is not always automatic in the LSP and running an explicit cache command is necessary. The code required to track checksums in the LSP would have been too complex for this PR, so that all goes through deno_graph now. The vendoring is still automatic when running from the CLI.
This commit is contained in:
parent
052b7d8bbd
commit
4f80d83774
27 changed files with 766 additions and 242 deletions
8
cli/cache/mod.rs
vendored
8
cli/cache/mod.rs
vendored
|
@ -196,8 +196,7 @@ impl Loader for FetchCacher {
|
|||
fn load(
|
||||
&mut self,
|
||||
specifier: &ModuleSpecifier,
|
||||
_is_dynamic: bool,
|
||||
cache_setting: deno_graph::source::CacheSetting,
|
||||
options: deno_graph::source::LoadOptions,
|
||||
) -> LoadFuture {
|
||||
use deno_graph::source::CacheSetting as LoaderCacheSetting;
|
||||
|
||||
|
@ -222,7 +221,7 @@ impl Loader for FetchCacher {
|
|||
let specifier = specifier.clone();
|
||||
|
||||
async move {
|
||||
let maybe_cache_setting = match cache_setting {
|
||||
let maybe_cache_setting = match options.cache_setting {
|
||||
LoaderCacheSetting::Use => None,
|
||||
LoaderCacheSetting::Reload => {
|
||||
if matches!(file_fetcher.cache_setting(), CacheSetting::Only) {
|
||||
|
@ -240,6 +239,7 @@ impl Loader for FetchCacher {
|
|||
permissions,
|
||||
maybe_accept: None,
|
||||
maybe_cache_setting: maybe_cache_setting.as_ref(),
|
||||
maybe_checksum: options.maybe_checksum,
|
||||
})
|
||||
.await
|
||||
.map(|file| {
|
||||
|
@ -269,7 +269,7 @@ impl Loader for FetchCacher {
|
|||
let error_class_name = get_error_class_name(&err);
|
||||
match error_class_name {
|
||||
"NotFound" => Ok(None),
|
||||
"NotCached" if cache_setting == LoaderCacheSetting::Only => Ok(None),
|
||||
"NotCached" if options.cache_setting == LoaderCacheSetting::Only => Ok(None),
|
||||
_ => Err(err),
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue