mirror of https://github.com/gorhill/uBlock.git
fine tune fix #3006
This commit is contained in:
parent
d6173b5d93
commit
f10fb29714
|
@ -1136,12 +1136,7 @@ vAPI.cloud = (function() {
|
||||||
var maxChunkCountPerItem = Math.floor(512 * 0.75) & ~(chunkCountPerFetch - 1);
|
var maxChunkCountPerItem = Math.floor(512 * 0.75) & ~(chunkCountPerFetch - 1);
|
||||||
|
|
||||||
// Mind chrome.storage.sync.QUOTA_BYTES_PER_ITEM (8192 at time of writing)
|
// Mind chrome.storage.sync.QUOTA_BYTES_PER_ITEM (8192 at time of writing)
|
||||||
// https://github.com/gorhill/uBlock/issues/3006
|
var maxChunkSize = chrome.storage.sync.QUOTA_BYTES_PER_ITEM || 8192;
|
||||||
// For Firefox, we will use a higher ratio to allow for more overhead for
|
|
||||||
// the infrastructure. Unfortunately this leads to less usable space for
|
|
||||||
// actual data, but all of this is provided for free by browser vendors,
|
|
||||||
// so we need to accept and deal with these limitations.
|
|
||||||
var maxChunkSize = Math.floor(chrome.storage.sync.QUOTA_BYTES_PER_ITEM * 0.75 || 5120);
|
|
||||||
|
|
||||||
// Mind chrome.storage.sync.QUOTA_BYTES (128 kB at time of writing)
|
// Mind chrome.storage.sync.QUOTA_BYTES (128 kB at time of writing)
|
||||||
// Firefox:
|
// Firefox:
|
||||||
|
@ -1149,6 +1144,19 @@ vAPI.cloud = (function() {
|
||||||
// > You can store up to 100KB of data using this API/
|
// > You can store up to 100KB of data using this API/
|
||||||
var maxStorageSize = chrome.storage.sync.QUOTA_BYTES || 102400;
|
var maxStorageSize = chrome.storage.sync.QUOTA_BYTES || 102400;
|
||||||
|
|
||||||
|
// Flavor-specific handling needs to be done here. Reason: to allow time
|
||||||
|
// for vAPI.webextFlavor to be properly set.
|
||||||
|
// https://github.com/gorhill/uBlock/issues/3006
|
||||||
|
// For Firefox, we will use a lower ratio to allow for more overhead for
|
||||||
|
// the infrastructure. Unfortunately this leads to less usable space for
|
||||||
|
// actual data, but all of this is provided for free by browser vendors,
|
||||||
|
// so we need to accept and deal with these limitations.
|
||||||
|
var initialize = function() {
|
||||||
|
var ratio = vAPI.webextFlavor.startsWith('Mozilla-Firefox-') ? 0.5 : 0.75;
|
||||||
|
maxChunkSize = Math.floor(maxChunkSize * ratio);
|
||||||
|
initialize = function(){};
|
||||||
|
};
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
defaultDeviceName: window.navigator.platform,
|
defaultDeviceName: window.navigator.platform,
|
||||||
deviceName: vAPI.localStorage.getItem('deviceName') || ''
|
deviceName: vAPI.localStorage.getItem('deviceName') || ''
|
||||||
|
@ -1205,6 +1213,8 @@ vAPI.cloud = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var push = function(dataKey, data, callback) {
|
var push = function(dataKey, data, callback) {
|
||||||
|
initialize();
|
||||||
|
|
||||||
var bin = {
|
var bin = {
|
||||||
'source': options.deviceName || options.defaultDeviceName,
|
'source': options.deviceName || options.defaultDeviceName,
|
||||||
'tstamp': Date.now(),
|
'tstamp': Date.now(),
|
||||||
|
@ -1239,6 +1249,8 @@ vAPI.cloud = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
var pull = function(dataKey, callback) {
|
var pull = function(dataKey, callback) {
|
||||||
|
initialize();
|
||||||
|
|
||||||
var assembleChunks = function(bin) {
|
var assembleChunks = function(bin) {
|
||||||
if ( chrome.runtime.lastError ) {
|
if ( chrome.runtime.lastError ) {
|
||||||
callback(null, chrome.runtime.lastError.message);
|
callback(null, chrome.runtime.lastError.message);
|
||||||
|
|
Loading…
Reference in New Issue