tag2
This commit is contained in:
@@ -67,9 +67,8 @@ class Local {
|
||||
return 5 * 1024 * 1024 - storage.local.getUseSize();
|
||||
}
|
||||
|
||||
dynamicClear(ctt) {
|
||||
dynamicClear() {
|
||||
if (storage.local.getAvailableSize() < 1 * 1024 * 1024) {
|
||||
|
||||
//remove commited
|
||||
for (let i = 0, len = localStorage.length; i < len; i++) {
|
||||
let key = localStorage.key(i);
|
||||
@@ -86,26 +85,42 @@ class Local {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove expired
|
||||
if (storage.local.getAvailableSize() < 1 * 1024 * 1024) {
|
||||
for (let i = 0, len = localStorage.length; i < len; i++) {
|
||||
let key = localStorage.key(i);
|
||||
if (null == key) {
|
||||
continue;
|
||||
}
|
||||
let value = localStorage.getItem(key);
|
||||
dynamicDeepClear(ctt, excludeKey) {
|
||||
if (!ctt) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.length == 37 && key.endsWith(".text") && value.length > 50) {
|
||||
let starray = value.split("|");
|
||||
let fl = starray[2];
|
||||
let ts = starray[3];
|
||||
//remove expired
|
||||
let availableSize = storage.local.getAvailableSize();
|
||||
|
||||
if (fl == "0") {
|
||||
if (ctt - ts > 3 * 24 * 3600 * 1000) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
for (
|
||||
let i = 0, len = localStorage.length;
|
||||
i < len && availableSize < 2 * 1024 * 1024;
|
||||
i++
|
||||
) {
|
||||
let key = localStorage.key(i);
|
||||
if (null == key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.indexOf(excludeKey) >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let value = localStorage.getItem(key);
|
||||
|
||||
if (key.length == 37 && key.endsWith(".text") && value.length > 50) {
|
||||
let starray = value.split("|");
|
||||
let fl = starray[2];
|
||||
let ts = starray[3];
|
||||
|
||||
if (fl == "0") {
|
||||
if (ctt - ts > 3 * 24 * 3600 * 1000) {
|
||||
localStorage.removeItem(key);
|
||||
availableSize = availableSize + value.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user