mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 05:04:48 +00:00
fix(install): bust packument cache on version not found when loading extra info from lockfile (#29679)
Some checks are pending
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / build wasm32 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Some checks are pending
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / build wasm32 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Co-authored-by: nathanwhit <nathanwhit@users.noreply.github.com>
This commit is contained in:
parent
64a95cb5fb
commit
d5f0dd7ca2
5 changed files with 98 additions and 48 deletions
|
@ -226,7 +226,7 @@ impl<THttpClient: NpmCacheHttpClient, TSys: NpmCacheSys>
|
|||
self: &Arc<Self>,
|
||||
name: &str,
|
||||
) -> Result<Option<Arc<NpmPackageInfo>>, LoadPackageInfoInnerError> {
|
||||
let (cache_item, clear_id) = {
|
||||
let (value_creator, clear_id) = {
|
||||
let mut mem_cache = self.memory_cache.lock();
|
||||
let cache_item = if let Some(cache_item) = mem_cache.get(name) {
|
||||
cache_item.clone()
|
||||
|
@ -240,53 +240,53 @@ impl<THttpClient: NpmCacheHttpClient, TSys: NpmCacheSys>
|
|||
mem_cache.insert(name.to_string(), cache_item.clone());
|
||||
cache_item
|
||||
};
|
||||
(cache_item, mem_cache.clear_id)
|
||||
match cache_item {
|
||||
MemoryCacheItem::FsCached(info) => return Ok(Some(info)),
|
||||
MemoryCacheItem::MemoryCached(maybe_info) => {
|
||||
return maybe_info.map_err(LoadPackageInfoInnerError)
|
||||
}
|
||||
MemoryCacheItem::Pending(value_creator) => {
|
||||
(value_creator, mem_cache.clear_id)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
match cache_item {
|
||||
MemoryCacheItem::FsCached(info) => Ok(Some(info)),
|
||||
MemoryCacheItem::MemoryCached(maybe_info) => {
|
||||
maybe_info.clone().map_err(LoadPackageInfoInnerError)
|
||||
match value_creator.get().await {
|
||||
Ok(FutureResult::SavedFsCache(info)) => {
|
||||
// return back the future and mark this package as having
|
||||
// been saved in the cache for next time it's requested
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::FsCached(info.clone()),
|
||||
);
|
||||
Ok(Some(info))
|
||||
}
|
||||
MemoryCacheItem::Pending(value_creator) => {
|
||||
match value_creator.get().await {
|
||||
Ok(FutureResult::SavedFsCache(info)) => {
|
||||
// return back the future and mark this package as having
|
||||
// been saved in the cache for next time it's requested
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::FsCached(info.clone()),
|
||||
);
|
||||
Ok(Some(info))
|
||||
}
|
||||
Ok(FutureResult::ErroredFsCache(info)) => {
|
||||
// since saving to the fs cache failed, keep the package information in memory
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Ok(Some(info.clone()))),
|
||||
);
|
||||
Ok(Some(info))
|
||||
}
|
||||
Ok(FutureResult::PackageNotExists) => {
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Ok(None)),
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
Err(err) => {
|
||||
let return_err = err.clone();
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Err(err)),
|
||||
);
|
||||
Err(LoadPackageInfoInnerError(return_err))
|
||||
}
|
||||
}
|
||||
Ok(FutureResult::ErroredFsCache(info)) => {
|
||||
// since saving to the fs cache failed, keep the package information in memory
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Ok(Some(info.clone()))),
|
||||
);
|
||||
Ok(Some(info))
|
||||
}
|
||||
Ok(FutureResult::PackageNotExists) => {
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Ok(None)),
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
Err(err) => {
|
||||
let return_err = err.clone();
|
||||
self.memory_cache.lock().try_insert(
|
||||
clear_id,
|
||||
name,
|
||||
MemoryCacheItem::MemoryCached(Err(err)),
|
||||
);
|
||||
Err(LoadPackageInfoInnerError(return_err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue