Fixed bug in chunked storage causing shrunk items not to be retrieved correctly.
This commit is contained in:
parent
d196982cd5
commit
7f4c3450fd
|
@ -6038,9 +6038,12 @@ org.sn
|
|||
perso.sn
|
||||
univ.sn
|
||||
|
||||
// so : http://www.soregistry.com/
|
||||
// so : http://sonic.so/policies/
|
||||
so
|
||||
com.so
|
||||
edu.so
|
||||
gov.so
|
||||
me.so
|
||||
net.so
|
||||
org.so
|
||||
|
||||
|
@ -7075,7 +7078,7 @@ org.zw
|
|||
|
||||
// newGTLDs
|
||||
|
||||
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2019-09-26T16:43:02Z
|
||||
// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2019-10-13T16:52:09Z
|
||||
// This list is auto-generated, don't edit it manually.
|
||||
// aaa : 2015-02-26 American Automobile Association, Inc.
|
||||
aaa
|
||||
|
@ -10440,7 +10443,7 @@ xin
|
|||
// xn--cg4bki : 2013-09-27 SAMSUNG SDS CO., LTD
|
||||
삼성
|
||||
|
||||
// xn--czr694b : 2014-01-16 Dot Trademark TLD Holding Company Limited
|
||||
// xn--czr694b : 2014-01-16 Internet DotTrademark Organisation Limited
|
||||
商标
|
||||
|
||||
// xn--czrs0t : 2013-12-19 Binky Moon, LLC
|
||||
|
@ -10497,7 +10500,7 @@ xin
|
|||
// xn--i1b6b1a6a2e : 2013-11-14 Public Interest Registry
|
||||
संगठन
|
||||
|
||||
// xn--imr513n : 2014-12-11 Dot Trademark TLD Holding Company Limited
|
||||
// xn--imr513n : 2014-12-11 Internet DotTrademark Organisation Limited
|
||||
餐厅
|
||||
|
||||
// xn--io0a7i : 2013-11-14 China Internet Network Information Center (CNNIC)
|
||||
|
@ -10566,7 +10569,7 @@ xin
|
|||
// xn--nyqy26a : 2014-11-07 Stable Tone Limited
|
||||
健康
|
||||
|
||||
// xn--otu796d : 2017-08-06 Dot Trademark TLD Holding Company Limited
|
||||
// xn--otu796d : 2017-08-06 Internet DotTrademark Organisation Limited
|
||||
招聘
|
||||
|
||||
// xn--p1acf : 2013-12-12 Rusnames Limited
|
||||
|
|
|
@ -71,12 +71,14 @@ var Storage = (() => {
|
|||
// Firefox Sync's max object BYTEs size is 16384, Chrome's 8192.
|
||||
// Rather than mesuring actual bytes, we play it safe by halving then
|
||||
// lowest to cope with escapes / multibyte characters.
|
||||
let removeKeys = [];
|
||||
for (let k of Object.keys(keys)) {
|
||||
let s = JSON.stringify(keys[k]);
|
||||
let chunksCountKey = chunksKey(k);
|
||||
let oldCount = await browser.storage.sync.get(chunksCountKey)[chunksCountKey] || 0;
|
||||
let count;
|
||||
if (s.length > MAX_ITEM_SIZE) {
|
||||
let count = Math.ceil(s.length / MAX_ITEM_SIZE);
|
||||
let chunksCountKey = chunksKey(k);
|
||||
let oldCount = await browser.storage.sync.get(chunksCountKey);
|
||||
count = Math.ceil(s.length / MAX_ITEM_SIZE);
|
||||
let chunks = {
|
||||
[chunksCountKey]: count
|
||||
};
|
||||
|
@ -85,15 +87,17 @@ var Storage = (() => {
|
|||
}
|
||||
await browser.storage.sync.set(chunks);
|
||||
keys[k] = "[CHUNKED]";
|
||||
if (oldCount-- > count) {
|
||||
let oldChunks = [];
|
||||
do {
|
||||
oldChunks.push(`${k}${oldCount}`);
|
||||
} while(oldCount-- > count);
|
||||
await browser.storage.sync.remove(oldChunks);
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
removeKeys.push(chunksCountKey);
|
||||
}
|
||||
if (oldCount-- > count) {
|
||||
do {
|
||||
removeKeys.push(`${k}${oldCount}`);
|
||||
} while(oldCount-- > count);
|
||||
}
|
||||
}
|
||||
await browser.storage.sync.remove(removeKeys);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -56,6 +56,13 @@
|
|||
async () => await eq("small2", "k", 3),
|
||||
async () => await eq("bigObject", "k0000", "v0000"),
|
||||
async () => await eq("hugeObject", "k0001", "v0001"),
|
||||
async () => {
|
||||
let key = "bigObject";
|
||||
let wasChunked = await Storage.isChunked(key);
|
||||
await Storage.set("sync", {[key]: {tiny: "prop"}});
|
||||
return wasChunked && !(await Storage.isChunked(key));
|
||||
},
|
||||
async () => eq("bigObject", "tiny", "prop"),
|
||||
async () => {
|
||||
await Storage.remove("sync", keys);
|
||||
let myItems = await Storage.get("sync", keys);
|
||||
|
|
Loading…
Reference in New Issue