@@ -27,6 +27,7 @@ import { CancelledSyncError, FailsafeError } from '../../errors/Error'
2727
2828import NextcloudBookmarksAdapter from '../adapters/NextcloudBookmarks'
2929import CachingAdapter from '../adapters/Caching'
30+ import LocalTabs from '../LocalTabs'
3031
3132const ACTION_CONCURRENCY = 12
3233
@@ -424,27 +425,55 @@ export default class SyncProcess {
424425
425426 const newMappings = [ ]
426427
427- // if we have the cache available, Diff cache and both trees
428- const localScanner = new Scanner (
429- this . cacheTreeRoot ,
430- this . localTreeRoot ,
431- ( oldItem , newItem ) =>
432- ( oldItem . type === newItem . type && String ( oldItem . id ) === String ( newItem . id ) ) ,
433- this . preserveOrder
434- )
435- const serverScanner = new Scanner (
436- this . cacheTreeRoot ,
437- this . serverTreeRoot ,
438- // We also allow canMergeWith here, because e.g. for NextcloudFolders the id of moved bookmarks changes (because their id is "<bookmarkID>;<folderId>")
439- ( oldItem , newItem ) => {
440- if ( ( oldItem . type === newItem . type && Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) || ( oldItem . type === 'bookmark' && oldItem . canMergeWith ( newItem ) ) ) {
441- newMappings . push ( [ oldItem , newItem ] )
442- return true
443- }
444- return false
445- } ,
446- this . preserveOrder
447- )
428+ let localScanner , serverScanner
429+ if ( this . localTree instanceof LocalTabs ) {
430+ // if we have the cache available, Diff cache and both trees
431+ localScanner = new Scanner (
432+ this . cacheTreeRoot ,
433+ this . localTreeRoot ,
434+ // We also allow canMergeWith for folders here, because Window IDs are not stable
435+ ( oldItem , newItem ) =>
436+ ( oldItem . type === newItem . type && String ( oldItem . id ) === String ( newItem . id ) ) || ( oldItem . type === 'folder' && oldItem . canMergeWith ( newItem ) ) ,
437+ this . preserveOrder ,
438+ )
439+ serverScanner = new Scanner (
440+ this . cacheTreeRoot ,
441+ this . serverTreeRoot ,
442+ // We also allow canMergeWith here
443+ // (for bookmarks, because e.g. for NextcloudFolders the id of moved bookmarks changes (because their id is "<bookmarkID>;<folderId>")
444+ // (for folders because Window IDs are not stable)
445+ ( oldItem , newItem ) => {
446+ if ( ( oldItem . type === newItem . type && Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) || ( oldItem . canMergeWith ( newItem ) ) ) {
447+ newMappings . push ( [ oldItem , newItem ] )
448+ return true
449+ }
450+ return false
451+ } ,
452+ this . preserveOrder ,
453+ )
454+ } else {
455+ // if we have the cache available, Diff cache and both trees
456+ localScanner = new Scanner (
457+ this . cacheTreeRoot ,
458+ this . localTreeRoot ,
459+ ( oldItem , newItem ) =>
460+ ( oldItem . type === newItem . type && String ( oldItem . id ) === String ( newItem . id ) ) ,
461+ this . preserveOrder
462+ )
463+ serverScanner = new Scanner (
464+ this . cacheTreeRoot ,
465+ this . serverTreeRoot ,
466+ // We also allow canMergeWith here, because e.g. for NextcloudFolders the id of moved bookmarks changes (because their id is "<bookmarkID>;<folderId>")
467+ ( oldItem , newItem ) => {
468+ if ( ( oldItem . type === newItem . type && Mappings . mappable ( mappingsSnapshot , oldItem , newItem ) ) || ( oldItem . type === 'bookmark' && oldItem . canMergeWith ( newItem ) ) ) {
469+ newMappings . push ( [ oldItem , newItem ] )
470+ return true
471+ }
472+ return false
473+ } ,
474+ this . preserveOrder
475+ )
476+ }
448477 Logger . log ( 'Calculating diffs for local and server trees relative to cache tree' )
449478 const localScanResult = await localScanner . run ( )
450479 const serverScanResult = await serverScanner . run ( )
0 commit comments