mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 05:42:25 -05:00
fix(ext/cache): gracefully error when cache creation failed (#26895)
Removes panic reported in https://github.com/denoland/deno/issues/26893
This commit is contained in:
parent
99d5c6e423
commit
768c5ea2bb
1 changed files with 8 additions and 1 deletions
9
ext/cache/sqlite.rs
vendored
9
ext/cache/sqlite.rs
vendored
|
@ -8,6 +8,7 @@ use std::time::SystemTime;
|
|||
use std::time::UNIX_EPOCH;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use deno_core::anyhow::Context;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::futures::future::poll_fn;
|
||||
use deno_core::parking_lot::Mutex;
|
||||
|
@ -45,7 +46,13 @@ impl SqliteBackedCache {
|
|||
pub fn new(cache_storage_dir: PathBuf) -> Result<Self, CacheError> {
|
||||
{
|
||||
std::fs::create_dir_all(&cache_storage_dir)
|
||||
.expect("failed to create cache dir");
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Failed to create cache storage directory {}",
|
||||
cache_storage_dir.display()
|
||||
)
|
||||
})
|
||||
.map_err(CacheError::Other)?;
|
||||
let path = cache_storage_dir.join("cache_metadata.db");
|
||||
let connection = rusqlite::Connection::open(&path).unwrap_or_else(|_| {
|
||||
panic!("failed to open cache db at {}", path.display())
|
||||
|
|
Loading…
Reference in a new issue