mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
fix(webstorage): increase localStorage limit to 10MB (#11081)
This commit is contained in:
parent
99dc674a36
commit
843b5476ba
1 changed files with 3 additions and 1 deletions
|
@ -15,6 +15,8 @@ use std::path::PathBuf;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct OriginStorageDir(PathBuf);
|
struct OriginStorageDir(PathBuf);
|
||||||
|
|
||||||
|
const MAX_STORAGE_BYTES: u32 = 10 * 1024 * 1024;
|
||||||
|
|
||||||
pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
|
pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
|
||||||
Extension::builder()
|
Extension::builder()
|
||||||
.js(include_js_files!(
|
.js(include_js_files!(
|
||||||
|
@ -136,7 +138,7 @@ pub fn op_webstorage_set(
|
||||||
conn.prepare("SELECT SUM(pgsize) FROM dbstat WHERE name = 'data'")?;
|
conn.prepare("SELECT SUM(pgsize) FROM dbstat WHERE name = 'data'")?;
|
||||||
let size: u32 = stmt.query_row(params![], |row| row.get(0))?;
|
let size: u32 = stmt.query_row(params![], |row| row.get(0))?;
|
||||||
|
|
||||||
if size >= 5000000 {
|
if size >= MAX_STORAGE_BYTES {
|
||||||
return Err(
|
return Err(
|
||||||
deno_web::DomExceptionQuotaExceededError::new(
|
deno_web::DomExceptionQuotaExceededError::new(
|
||||||
"Exceeded maximum storage size",
|
"Exceeded maximum storage size",
|
||||||
|
|
Loading…
Reference in a new issue