From 57e0f7b34d57fa891357ef6054de704532912559 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 16 Aug 2026 17:11:03 +0200 Subject: [PATCH] fix(CachingTreeWrapper): Avoid collisions between Chromium IDs and CachingAdapter IDs fixes #2332 Signed-off-by: Marcel Klehr --- src/lib/CacheTree.ts | 4 ++++ src/lib/CachingTreeWrapper.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/lib/CacheTree.ts b/src/lib/CacheTree.ts index 4d5458087c..a57b0600d7 100644 --- a/src/lib/CacheTree.ts +++ b/src/lib/CacheTree.ts @@ -43,4 +43,8 @@ export default class CacheTree extends CachingAdapter implements IResource { return Promise.resolve(true) } + + setHighestId(id: number) { + this.highestId = Math.max(this.highestId, id) + } } \ No newline at end of file diff --git a/src/lib/CachingTreeWrapper.ts b/src/lib/CachingTreeWrapper.ts index 08ef4ee668..5f7b0cd6e4 100644 --- a/src/lib/CachingTreeWrapper.ts +++ b/src/lib/CachingTreeWrapper.ts @@ -24,6 +24,9 @@ export default class CachingTreeWrapper implements OrderFolderResource): Promise { const id = await this.innerTree.createBookmark(bookmark) + // In case the browser uses positive int IDs, we need to reset the highestId counter here + // to avoid collisions with the cache tree's auto-generated IDs + this.cacheTree.setHighestId(Number(id) || 0) const cacheId = await this.cacheTree.createBookmark(bookmark.copy(false)) const cacheBookmark = this.cacheTree.bookmarksCache.findBookmark(cacheId) this.cacheTree.bookmarksCache.removeFromIndex(cacheBookmark) @@ -46,6 +49,9 @@ export default class CachingTreeWrapper implements OrderFolderResource): Promise { const id = await this.innerTree.createFolder(folder) + // In case the browser uses positive int IDs, we need to reset the highestId counter here + // to avoid collisions with the cache tree's auto-generated IDs + this.cacheTree.setHighestId(Number(id) || 0) const cacheId = await this.cacheTree.createFolder(folder.copy(false)) const cacheFolder = this.cacheTree.bookmarksCache.findFolder(cacheId) this.cacheTree.bookmarksCache.removeFromIndex(cacheFolder)