mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
parent
a7531361ef
commit
6e2d8c969c
1 changed files with 4 additions and 2 deletions
6
ext/cache/lib.rs
vendored
6
ext/cache/lib.rs
vendored
|
@ -6,6 +6,7 @@ use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op2;
|
use deno_core::op2;
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
|
@ -205,11 +206,12 @@ where
|
||||||
let mut state = state.borrow_mut();
|
let mut state = state.borrow_mut();
|
||||||
if let Some(cache) = state.try_borrow::<CA>() {
|
if let Some(cache) = state.try_borrow::<CA>() {
|
||||||
Ok(cache.clone())
|
Ok(cache.clone())
|
||||||
} else {
|
} else if let Some(create_cache) = state.try_borrow::<CreateCache<CA>>() {
|
||||||
let create_cache = state.borrow::<CreateCache<CA>>().clone();
|
|
||||||
let cache = create_cache.0();
|
let cache = create_cache.0();
|
||||||
state.put(cache);
|
state.put(cache);
|
||||||
Ok(state.borrow::<CA>().clone())
|
Ok(state.borrow::<CA>().clone())
|
||||||
|
} else {
|
||||||
|
Err(type_error("CacheStorage is not available in this context."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue