From 6284eca3512df03c3741e6f4e8e002cbf516065d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 24 Aug 2020 11:47:57 -0400 Subject: [PATCH] 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. --- platform/chromium/vapi-background.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 6bd301ae5..d5bbfd7a8 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -1522,8 +1522,6 @@ vAPI.cloud = (( ) => { maxChunkSize = evalMaxChunkSize(); }, { once: true }); - const maxStorageSize = QUOTA_BYTES; - const options = { defaultDeviceName: window.navigator.platform, deviceName: undefined, @@ -1562,13 +1560,7 @@ vAPI.cloud = (( ) => { const deleteChunks = async function(datakey, start) { const keys = []; - // No point in deleting more than: - // - The max number of chunks per item - // - The max number of chunks per storage limit - const n = Math.min( - maxChunkCountPerItem, - Math.ceil(maxStorageSize / maxChunkSize) - ); + const n = await getCoarseChunkCount(datakey); for ( let i = start; i < n; i++ ) { keys.push(datakey + i.toString()); } @@ -1612,7 +1604,7 @@ vAPI.cloud = (( ) => { // this will free storage space which could otherwise cause the push // operation to fail. try { - await deleteChunks(datakey, chunkCount); + await deleteChunks(datakey, chunkCount + 1); } catch (reason) { }