mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Fix ability to overwrite overquota'ed cloud storage
This commit fixes deleting all entries when cloud storage usage is beyond allowed limit. The issue would prevent pushing new data well within quota limit because the old data beyond limit was never removed in the first place.
This commit is contained in:
parent
63e2261ff7
commit
6284eca351
@ -1522,8 +1522,6 @@ vAPI.cloud = (( ) => {
|
|||||||
maxChunkSize = evalMaxChunkSize();
|
maxChunkSize = evalMaxChunkSize();
|
||||||
}, { once: true });
|
}, { once: true });
|
||||||
|
|
||||||
const maxStorageSize = QUOTA_BYTES;
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
defaultDeviceName: window.navigator.platform,
|
defaultDeviceName: window.navigator.platform,
|
||||||
deviceName: undefined,
|
deviceName: undefined,
|
||||||
@ -1562,13 +1560,7 @@ vAPI.cloud = (( ) => {
|
|||||||
const deleteChunks = async function(datakey, start) {
|
const deleteChunks = async function(datakey, start) {
|
||||||
const keys = [];
|
const keys = [];
|
||||||
|
|
||||||
// No point in deleting more than:
|
const n = await getCoarseChunkCount(datakey);
|
||||||
// - The max number of chunks per item
|
|
||||||
// - The max number of chunks per storage limit
|
|
||||||
const n = Math.min(
|
|
||||||
maxChunkCountPerItem,
|
|
||||||
Math.ceil(maxStorageSize / maxChunkSize)
|
|
||||||
);
|
|
||||||
for ( let i = start; i < n; i++ ) {
|
for ( let i = start; i < n; i++ ) {
|
||||||
keys.push(datakey + i.toString());
|
keys.push(datakey + i.toString());
|
||||||
}
|
}
|
||||||
@ -1612,7 +1604,7 @@ vAPI.cloud = (( ) => {
|
|||||||
// this will free storage space which could otherwise cause the push
|
// this will free storage space which could otherwise cause the push
|
||||||
// operation to fail.
|
// operation to fail.
|
||||||
try {
|
try {
|
||||||
await deleteChunks(datakey, chunkCount);
|
await deleteChunks(datakey, chunkCount + 1);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user