Skip to content

Commit 2ecec78

Browse files
authored
Merge pull request #2122 from floccusaddon/feat/improve-failsafe-wording
Failsafe: be more precise about where bookmarks are added/deleted
2 parents 5149670 + 62d9b94 commit 2ecec78

File tree

10 files changed

+137
-89
lines changed

10 files changed

+137
-89
lines changed

_locales/en/messages.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"message": "E028: Couldn't authenticate with the server."
8585
},
8686
"Error029": {
87-
"message": "E029: Failsafe: The current sync run would delete {0}% of your links. Refusing to execute. Disable this failsafe in the account settings if you want to proceed anyway."
87+
"message": "E029: Failsafe: The current sync run would delete {0}% of your links on the server. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway."
8888
},
8989
"Error030": {
9090
"message": "E030: Failed to decrypt bookmarks file. The passphrase may be wrong or the file may be corrupted."
@@ -126,7 +126,7 @@
126126
"message": "E042: Remote bookmarks file size could not be retrieved. It is impossible to verify that the bookmarks file was downloaded in full. If this error persists please contact the server administrator."
127127
},
128128
"Error043": {
129-
"message": "E043: Failsafe: The current sync run would increase your bookmarks count by {0}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway."
129+
"message": "E043: Failsafe: The current sync run would increase your links count on the server by {0}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway."
130130
},
131131
"Error044": {
132132
"message": "E044: Git push operation failed: {0}"
@@ -140,6 +140,12 @@
140140
"Error047": {
141141
"message": "E047: Failed to parse XBEL file. The XBEL data seems to be corrupted or incomplete. You can try removing the file on the server to let floccus recreate it. Make sure to take a backup first."
142142
},
143+
"Error049": {
144+
"message": "E049: Failsafe: The current sync run would increase your local links count in this profile by {0}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway."
145+
},
146+
"Error050": {
147+
"message": "E050: Failsafe: The current sync run would delete {0}% of your local links in this profile. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway."
148+
},
143149
"LabelWebdavurl": {
144150
"message": "WebDAV URL"
145151
},
@@ -532,7 +538,7 @@
532538
"message": "Failsafe"
533539
},
534540
"DescriptionFailsafe": {
535-
"message": "Sometimes configuration errors or software bugs can cause the unintended removal of data, which is then lost, or the unintended duplication of data, which is then hard to sort out. To prevent this from happening, floccus will not delete more than 20% of your bookmarks in one go and will also not add more than 20% to your bookmarks count in one go, unless you disable this failsafe here."
541+
"message": "Sometimes configuration errors or software bugs can cause the unintended removal of data, which is then lost, or the unintended duplication of data, which is then hard to sort out. To prevent this from happening, floccus will not delete more than 20% of your bookmarks in one go and will also not add more than 20% to your links count in one go, unless you disable this failsafe here."
536542
},
537543
"LabelFailsafeon": {
538544
"message": "Enabled. Will not delete or add more than 20% from/to your local bookmarks without asking you first. (Recommended)"

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const js = async function() {
109109
resolve()
110110
})
111111
)
112+
await new Promise(resolve => setTimeout(resolve, 5000))
112113
html(statsJson)
113114
}
114115

package-lock.json

Lines changed: 38 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function lazyLoadIntegration() {
2+
throw new Error('Cannot lazy load sources from network')
3+
}

src/errors/Error.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ export class InterruptedSyncError extends FloccusError {
240240

241241
// code 28 is unused
242242

243-
export class DeletionFailsafeError extends FloccusError {
243+
export class ServersideDeletionFailsafeError extends FloccusError {
244244
public percent: number
245245

246246
constructor(percent:number) {
247-
super(`E029: Failsafe: The current sync run would delete ${percent}% of your links. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
247+
super(`E029: Failsafe: The current sync run would delete ${percent}% of your links on the server. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
248248
this.code = 29
249249
this.percent = percent
250-
Object.setPrototypeOf(this, DeletionFailsafeError.prototype)
250+
Object.setPrototypeOf(this, ServersideDeletionFailsafeError.prototype)
251251
}
252252
}
253253

@@ -359,14 +359,14 @@ export class FileSizeUnknown extends FloccusError {
359359
}
360360
}
361361

362-
export class AdditionFailsafeError extends FloccusError {
362+
export class ServersideAdditionFailsafeError extends FloccusError {
363363
public percent: number
364364

365365
constructor(percent:number) {
366-
super(`E043: Failsafe: The current sync run would increase your bookmarks count by ${percent}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
366+
super(`E043: Failsafe: The current sync run would increase your links count on the server by ${percent}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
367367
this.code = 43
368368
this.percent = percent
369-
Object.setPrototypeOf(this, AdditionFailsafeError.prototype)
369+
Object.setPrototypeOf(this, ServersideAdditionFailsafeError.prototype)
370370
}
371371
}
372372

@@ -422,4 +422,26 @@ export class MappingFailureError extends FloccusError {
422422
this.code = 48
423423
Object.setPrototypeOf(this, MappingFailureError.prototype)
424424
}
425+
}
426+
427+
export class ClientsideAdditionFailsafeError extends FloccusError {
428+
public percent: number
429+
430+
constructor(percent:number) {
431+
super(`E049: Failsafe: The current sync run would increase your local links count in this profile by ${percent}%. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
432+
this.code = 49
433+
this.percent = percent
434+
Object.setPrototypeOf(this, ClientsideAdditionFailsafeError.prototype)
435+
}
436+
}
437+
438+
export class ClientsideDeletionFailsafeError extends FloccusError {
439+
public percent: number
440+
441+
constructor(percent:number) {
442+
super(`E050: Failsafe: The current sync run would delete ${percent}% of your local links in this profile. Refusing to execute. Disable this failsafe in the profile settings if you want to proceed anyway.`)
443+
this.code = 50
444+
this.percent = percent
445+
Object.setPrototypeOf(this, ClientsideDeletionFailsafeError.prototype)
446+
}
425447
}

src/lib/browser/BrowserAccount.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import browser from '../browser-api'
44
import AdapterFactory from '../AdapterFactory'
55
import Account from '../Account'
66
import {
7-
AdditionFailsafeError,
7+
ClientsideAdditionFailsafeError, ClientsideDeletionFailsafeError,
88
CreateBookmarkError,
9-
DeletionFailsafeError, FloccusError, GitPushError,
9+
FloccusError, GitPushError,
1010
HttpError,
1111
InconsistentBookmarksExistenceError, InvalidUrlError, LockFileError,
1212
MissingItemOrderError,
13-
ParseResponseError, UnexpectedFolderPathError,
13+
ParseResponseError, ServersideAdditionFailsafeError, ServersideDeletionFailsafeError, UnexpectedFolderPathError,
1414
UnknownFolderItemOrderError, UpdateBookmarkError
1515
} from '../../errors/Error'
1616
import {i18n} from '../native/I18n'
@@ -108,10 +108,16 @@ export default class BrowserAccount extends Account {
108108
if (er instanceof LockFileError) {
109109
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.status, er.lockFile])
110110
}
111-
if (er instanceof DeletionFailsafeError) {
111+
if (er instanceof ServersideDeletionFailsafeError) {
112112
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
113113
}
114-
if (er instanceof AdditionFailsafeError) {
114+
if (er instanceof ServersideAdditionFailsafeError) {
115+
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
116+
}
117+
if (er instanceof ClientsideDeletionFailsafeError) {
118+
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
119+
}
120+
if (er instanceof ClientsideAdditionFailsafeError) {
115121
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
116122
}
117123
if (er instanceof CreateBookmarkError) {

src/lib/native/NativeAccount.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import AdapterFactory from '../AdapterFactory'
44
import Account from '../Account'
55
import { IAccountData } from '../interfaces/AccountStorage'
66
import {
7-
AdditionFailsafeError,
7+
ClientsideAdditionFailsafeError, ClientsideDeletionFailsafeError,
88
CreateBookmarkError,
9-
DeletionFailsafeError, FloccusError, GitPushError,
9+
FloccusError, GitPushError,
1010
HttpError,
1111
InconsistentBookmarksExistenceError, InvalidUrlError, LockFileError,
1212
MissingItemOrderError,
13-
ParseResponseError, UnexpectedFolderPathError,
13+
ParseResponseError, ServersideAdditionFailsafeError, ServersideDeletionFailsafeError, UnexpectedFolderPathError,
1414
UnknownFolderItemOrderError, UpdateBookmarkError
1515
} from '../../errors/Error'
1616
import Logger from '../Logger'
@@ -85,10 +85,16 @@ export default class NativeAccount extends Account {
8585
if (er instanceof LockFileError) {
8686
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.status, er.lockFile])
8787
}
88-
if (er instanceof DeletionFailsafeError) {
88+
if (er instanceof ServersideDeletionFailsafeError) {
8989
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
9090
}
91-
if (er instanceof AdditionFailsafeError) {
91+
if (er instanceof ServersideAdditionFailsafeError) {
92+
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
93+
}
94+
if (er instanceof ClientsideDeletionFailsafeError) {
95+
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
96+
}
97+
if (er instanceof ClientsideAdditionFailsafeError) {
9298
return i18n.getMessage('Error' + String(er.code).padStart(3, '0'), [er.percent])
9399
}
94100
if (er instanceof CreateBookmarkError) {

0 commit comments

Comments
 (0)