parent
261d9d594b
commit
2960e5c5ce
1 changed files with 3 additions and 42 deletions
|
@ -128,12 +128,13 @@ const sync = {
|
||||||
await sync.checkForListenersMaybeAdd();
|
await sync.checkForListenersMaybeAdd();
|
||||||
|
|
||||||
async function updateSyncIdentities() {
|
async function updateSyncIdentities() {
|
||||||
const excludeRegExp = await getExcludeRegExp();
|
const { syncExcludeRegExp } = await browser.storage.local.get("syncExcludeRegExp");
|
||||||
|
const excludeRegExp = new RegExp(syncExcludeRegExp, "i");
|
||||||
const identities = await browser.contextualIdentities.query({});
|
const identities = await browser.contextualIdentities.query({});
|
||||||
|
|
||||||
for (const identity of identities) {
|
for (const identity of identities) {
|
||||||
// skip excluded identities
|
// skip excluded identities
|
||||||
if (excludeRegExpMatchesIdentity(excludeRegExp, identity)) {
|
if (identity.name.match(excludeRegExp)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +334,6 @@ async function restore() {
|
||||||
*/
|
*/
|
||||||
async function reconcileIdentities(){
|
async function reconcileIdentities(){
|
||||||
if (SYNC_DEBUG) console.log("reconcileIdentities");
|
if (SYNC_DEBUG) console.log("reconcileIdentities");
|
||||||
const excludeRegExp = await getExcludeRegExp();
|
|
||||||
|
|
||||||
// first delete any from the deleted list
|
// first delete any from the deleted list
|
||||||
const deletedIdentityList =
|
const deletedIdentityList =
|
||||||
|
@ -343,14 +343,6 @@ async function reconcileIdentities(){
|
||||||
const deletedCookieStoreId =
|
const deletedCookieStoreId =
|
||||||
await identityState.lookupCookieStoreId(deletedUUID);
|
await identityState.lookupCookieStoreId(deletedUUID);
|
||||||
if (deletedCookieStoreId){
|
if (deletedCookieStoreId){
|
||||||
if (excludeRegExp) {
|
|
||||||
const deletedIdentity = await identityState.get(deletedCookieStoreId);
|
|
||||||
// skip excluded identities
|
|
||||||
if (excludeRegExpMatchesIdentity(excludeRegExp, deletedIdentity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await browser.contextualIdentities.remove(deletedCookieStoreId);
|
await browser.contextualIdentities.remove(deletedCookieStoreId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -365,11 +357,6 @@ async function reconcileIdentities(){
|
||||||
await sync.storageArea.getIdentities();
|
await sync.storageArea.getIdentities();
|
||||||
// find any local dupes created on sync storage and delete from sync storage
|
// find any local dupes created on sync storage and delete from sync storage
|
||||||
for (const localIdentity of localIdentities) {
|
for (const localIdentity of localIdentities) {
|
||||||
// skip excluded identities
|
|
||||||
if (excludeRegExpMatchesIdentity(excludeRegExp, localIdentity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const syncIdentitiesOfName = syncIdentitiesRemoveDupes
|
const syncIdentitiesOfName = syncIdentitiesRemoveDupes
|
||||||
.filter(identity => identity.name === localIdentity.name);
|
.filter(identity => identity.name === localIdentity.name);
|
||||||
if (syncIdentitiesOfName.length > 1) {
|
if (syncIdentitiesOfName.length > 1) {
|
||||||
|
@ -383,11 +370,6 @@ async function reconcileIdentities(){
|
||||||
await sync.storageArea.getIdentities();
|
await sync.storageArea.getIdentities();
|
||||||
// now compare all containers for matching names.
|
// now compare all containers for matching names.
|
||||||
for (const syncIdentity of syncIdentities) {
|
for (const syncIdentity of syncIdentities) {
|
||||||
// skip excluded identities
|
|
||||||
if (excludeRegExpMatchesIdentity(excludeRegExp, syncIdentity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syncIdentity.macAddonUUID){
|
if (syncIdentity.macAddonUUID){
|
||||||
const localMatch = localIdentities.find(
|
const localMatch = localIdentities.find(
|
||||||
localIdentity => localIdentity.name === syncIdentity.name
|
localIdentity => localIdentity.name === syncIdentity.name
|
||||||
|
@ -603,24 +585,3 @@ async function setAssignmentWithUUID(assignedSite, urlKey) {
|
||||||
}
|
}
|
||||||
throw new Error (`No cookieStoreId found for: ${uuid}, ${urlKey}`);
|
throw new Error (`No cookieStoreId found for: ${uuid}, ${urlKey}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the sync exclude regexp from local storage.
|
|
||||||
async function getExcludeRegExp() {
|
|
||||||
const { syncExcludeRegExp } = await browser.storage.local.get("syncExcludeRegExp");
|
|
||||||
if (syncExcludeRegExp) {
|
|
||||||
return new RegExp(syncExcludeRegExp, "i");
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Matching the provided exclude regexp against the provided identity and return
|
|
||||||
// true if they match.
|
|
||||||
function excludeRegExpMatchesIdentity(excludeRegExp, identity) {
|
|
||||||
if (excludeRegExp && identity.name.match(excludeRegExp)) {
|
|
||||||
if (SYNC_DEBUG) console.log(`Exclude regexp matches identity '${identity.name}'`);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue