Skip to content

Commit 742bf34

Browse files
authored
Merge pull request #1917 from floccusaddon/fix/addition-failsafe-minimum
fix(Default#applyAdditionFailsafe): Only kick in if at least 20 bookmarks are being added
2 parents 9377b17 + df036b8 commit 742bf34

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/lib/strategies/Default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export default class SyncProcess {
383383

384384
Logger.log('Checking addition failsafe: ' + countAdded + '/' + countTotal + '=' + (countAdded / countTotal))
385385
// Failsafe kicks in if more than 20% is added or more than 1k bookmarks
386-
if (countTotal > 5 && (countAdded / countTotal > 0.2 || countAdded > 1000)) {
386+
if (countTotal > 5 && ((countAdded >= 20 && countAdded / countTotal > 0.2) || countAdded > 1000)) {
387387
const failsafe = this.server.getData().failsafe
388388
if (failsafe !== false || typeof failsafe === 'undefined') {
389389
throw new AdditionFailsafeError(Math.ceil((countAdded / countTotal) * 100))

src/test/test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,12 +2349,12 @@ describe('Floccus', function() {
23492349
})
23502350
// Create 6 bookmarks to be above the negligibility threshold
23512351
await Promise.all([
2352-
'http://ur.1l/',
2353-
'http://ur2.l/',
2354-
'http://ur3.l/',
2355-
'http://ur4.l/',
2356-
'http://ur5.l/',
2357-
'http://ur6.l/'
2352+
'http://ur1.ll/',
2353+
'http://ur2.ll/',
2354+
'http://ur3.ll/',
2355+
'http://ur4.ll/',
2356+
'http://ur5.ll/',
2357+
'http://ur6.ll/'
23582358
].map(url => browser.bookmarks.create({
23592359
title: 'url',
23602360
url,
@@ -2364,8 +2364,9 @@ describe('Floccus', function() {
23642364
expect(account.getData().error).to.not.be.ok
23652365

23662366
// Simulate an extreme increase of bookmarks
2367+
// More than 20 bookmarks need to be added at once to trigger the failsafe
23672368
await Promise.all([
2368-
'http://ur.1l/',
2369+
'http://ur1.l/',
23692370
'http://ur2.l/',
23702371
'http://ur3.l/',
23712372
'http://ur4.l/',
@@ -2375,7 +2376,7 @@ describe('Floccus', function() {
23752376
'http://ur8.l/',
23762377
'http://ur9.l/',
23772378
'http://ur10.l/',
2378-
'http://ur.11l/',
2379+
'http://ur11.l/',
23792380
'http://ur12.l/',
23802381
'http://ur13.l/',
23812382
'http://ur14.l/',
@@ -2385,6 +2386,7 @@ describe('Floccus', function() {
23852386
'http://ur18.l/',
23862387
'http://ur19.l/',
23872388
'http://ur20.l/',
2389+
'http://ur21.l/',
23882390
].map(url => browser.bookmarks.create({
23892391
title: 'url',
23902392
url,

0 commit comments

Comments
 (0)