@@ -27,7 +27,6 @@ import { CancelledSyncError, FailsafeError } from '../../errors/Error'
27
27
28
28
import NextcloudBookmarksAdapter from '../adapters/NextcloudBookmarks'
29
29
import CachingAdapter from '../adapters/Caching'
30
- import LocalTabs from '../LocalTabs'
31
30
32
31
const ACTION_CONCURRENCY = 12
33
32
@@ -437,8 +436,23 @@ export default class SyncProcess {
437
436
this . cacheTreeRoot ,
438
437
this . localTreeRoot ,
439
438
// We also allow canMergeWith for folders here, because Window IDs are not stable
440
- ( oldItem , newItem ) =>
441
- ( oldItem . type === newItem . type && String ( oldItem . id ) === String ( newItem . id ) ) || ( oldItem . type === 'folder' && oldItem . canMergeWith ( newItem ) ) ,
439
+ ( oldItem , newItem ) => {
440
+ if ( oldItem . type !== newItem . type ) {
441
+ return false
442
+ }
443
+ if ( oldItem . type === 'bookmark' && newItem . type === 'bookmark' ) {
444
+ return oldItem . url === newItem . url
445
+ }
446
+ if ( oldItem . type === 'folder' ) {
447
+ if ( String ( oldItem . id ) === String ( newItem . id ) ) {
448
+ return true
449
+ }
450
+ if ( oldItem . canMergeWith ( newItem ) ) {
451
+ return true
452
+ }
453
+ }
454
+ return false
455
+ } ,
442
456
this . preserveOrder ,
443
457
)
444
458
serverScanner = new Scanner (
@@ -448,9 +462,21 @@ export default class SyncProcess {
448
462
// (for bookmarks, because e.g. for NextcloudFolders the id of moved bookmarks changes (because their id is "<bookmarkID>;<folderId>")
449
463
// (for folders because Window IDs are not stable)
450
464
( oldItem , newItem ) => {
451
- if ( ( oldItem . type === newItem . type && Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) || ( oldItem . canMergeWith ( newItem ) ) ) {
452
- newMappings . push ( [ oldItem , newItem ] )
453
- return true
465
+ if ( oldItem . type !== newItem . type ) {
466
+ return false
467
+ }
468
+ if ( oldItem . type === 'bookmark' && newItem . type === 'bookmark' ) {
469
+ return oldItem . url === newItem . url
470
+ }
471
+ if ( oldItem . type === 'folder' ) {
472
+ if ( Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) {
473
+ newMappings . push ( [ oldItem , newItem ] )
474
+ return true
475
+ }
476
+ if ( oldItem . canMergeWith ( newItem ) ) {
477
+ newMappings . push ( [ oldItem , newItem ] )
478
+ return true
479
+ }
454
480
}
455
481
return false
456
482
} ,
@@ -461,18 +487,47 @@ export default class SyncProcess {
461
487
localScanner = new Scanner (
462
488
this . cacheTreeRoot ,
463
489
this . localTreeRoot ,
464
- ( oldItem , newItem ) =>
465
- ( oldItem . type === newItem . type && String ( oldItem . id ) === String ( newItem . id ) ) ,
490
+ ( oldItem , newItem ) => {
491
+ if ( oldItem . type !== newItem . type ) {
492
+ return false
493
+ }
494
+ if ( oldItem . type === 'folder' ) {
495
+ if ( String ( oldItem . id ) === String ( newItem . id ) ) {
496
+ return true
497
+ }
498
+ }
499
+ if ( oldItem . type === 'bookmark' && newItem . type === 'bookmark' ) {
500
+ if ( String ( oldItem . id ) === String ( newItem . id ) && oldItem . url === newItem . url ) {
501
+ return true
502
+ }
503
+ }
504
+ return false
505
+ } ,
466
506
this . preserveOrder
467
507
)
468
508
serverScanner = new Scanner (
469
509
this . cacheTreeRoot ,
470
510
this . serverTreeRoot ,
471
511
// We also allow canMergeWith here, because e.g. for NextcloudFolders the id of moved bookmarks changes (because their id is "<bookmarkID>;<folderId>")
472
512
( oldItem , newItem ) => {
473
- if ( ( oldItem . type === newItem . type && Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) || ( oldItem . type === 'bookmark' && oldItem . canMergeWith ( newItem ) ) ) {
474
- newMappings . push ( [ oldItem , newItem ] )
475
- return true
513
+ if ( oldItem . type !== newItem . type ) {
514
+ return false
515
+ }
516
+ if ( oldItem . type === 'folder' ) {
517
+ if ( Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) {
518
+ newMappings . push ( [ oldItem , newItem ] )
519
+ return true
520
+ }
521
+ }
522
+ if ( oldItem . type === 'bookmark' && newItem . type === 'bookmark' ) {
523
+ if ( Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) && oldItem . url === newItem . url ) {
524
+ newMappings . push ( [ oldItem , newItem ] )
525
+ return true
526
+ }
527
+ if ( oldItem . canMergeWith ( newItem ) ) {
528
+ newMappings . push ( [ oldItem , newItem ] )
529
+ return true
530
+ }
476
531
}
477
532
return false
478
533
} ,
@@ -856,7 +911,6 @@ export default class SyncProcess {
856
911
}
857
912
858
913
if ( action . payload instanceof Folder && action . payload . children . length && action . oldItem instanceof Folder ) {
859
-
860
914
// Fix for Unidirectional reverted REMOVEs, for all other strategies this should be a noop
861
915
action . payload . children . forEach ( ( item ) => {
862
916
item . parentId = id
0 commit comments