Do not fall back to alternative cache backend if selected one fails

Default behavior is to fall back to an alternative backend
if the uBO-selected one is not available. However there will be
no fall back when the `cacheStorageAPI` is set to one specific
backend by the user.
This commit is contained in:
Raymond Hill 2019-02-20 07:05:45 -05:00
parent 87feb47b51
commit b585518c00
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 6 deletions

View File

@ -112,15 +112,16 @@
}); });
}); });
}, },
select: function(backend) { select: function(selectedBackend) {
if ( backend === undefined || backend === 'unset' ) { let actualBackend = selectedBackend;
backend = vAPI.webextFlavor.soup.has('firefox') if ( actualBackend === undefined || actualBackend === 'unset' ) {
actualBackend = vAPI.webextFlavor.soup.has('firefox')
? 'indexedDB' ? 'indexedDB'
: 'browser.storage.local'; : 'browser.storage.local';
} }
if ( backend === 'indexedDB' ) { if ( actualBackend === 'indexedDB' ) {
return selectIDB().then(success => { return selectIDB().then(success => {
if ( success ) { if ( success || selectedBackend === 'indexedDB' ) {
clearWebext(); clearWebext();
return 'indexedDB'; return 'indexedDB';
} }
@ -128,7 +129,7 @@
return 'browser.storage.local'; return 'browser.storage.local';
}); });
} }
if ( backend === 'browser.storage.local' ) { if ( actualBackend === 'browser.storage.local' ) {
clearIDB(); clearIDB();
} }
return Promise.resolve('browser.storage.local'); return Promise.resolve('browser.storage.local');