Skip to content

Commit 7733fbb

Browse files
committed
fix(Non-Atomic adapters): Reduce HTTP request parallelism for better throughput
Signed-off-by: Marcel Klehr <[email protected]>
1 parent cc5b42b commit 7733fbb

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/lib/adapters/Karakeep.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class KarakeepAdapter implements Adapter, IResource<typeof ItemLo
3838

3939
constructor(server: KarakeepConfig) {
4040
this.server = server
41-
this.fetchQueue = new PQueue({ concurrency: 12 })
41+
this.fetchQueue = new PQueue({ concurrency: 5 })
4242
this.abortController = new AbortController()
4343
this.abortSignal = this.abortController.signal
4444
}

src/lib/adapters/Linkwarden.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class LinkwardenAdapter implements Adapter, IResource<typeof Item
3737

3838
constructor(server: LinkwardenConfig) {
3939
this.server = server
40-
this.fetchQueue = new PQueue({ concurrency: 12 })
40+
this.fetchQueue = new PQueue({ concurrency: 5 })
4141
this.abortController = new AbortController()
4242
this.abortSignal = this.abortController.signal
4343
}

src/lib/adapters/NextcloudBookmarks.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
6767
private server: NextcloudBookmarksConfig
6868
private fetchQueue: PQueue<{ concurrency: 12 }>
6969
private bookmarkLock: AsyncLock
70+
private importLock: AsyncLock
7071
private list: Bookmark<typeof ItemLocation.SERVER>[]
7172
private tree: Folder<typeof ItemLocation.SERVER>
7273
private canceled = false
@@ -83,8 +84,9 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
8384

8485
constructor(server: NextcloudBookmarksConfig) {
8586
this.server = server
86-
this.fetchQueue = new PQueue({ concurrency: 12 })
87+
this.fetchQueue = new PQueue({ concurrency: 5 })
8788
this.bookmarkLock = new AsyncLock()
89+
this.importLock = new AsyncLock()
8890
}
8991

9092
static getDefaultValues(): NextcloudBookmarksConfig {
@@ -463,12 +465,14 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
463465
const body = new FormData()
464466
body.append('bm_import', blob, 'upload.html')
465467

466-
const json = await this.sendRequest(
467-
'POST',
468-
`index.php/apps/bookmarks/public/rest/v2/folder/${parentId}/import`,
469-
'multipart/form-data',
470-
body
471-
)
468+
const json = this.importLock.acquire('import', async () => {
469+
return this.sendRequest(
470+
'POST',
471+
`index.php/apps/bookmarks/public/rest/v2/folder/${parentId}/import`,
472+
'multipart/form-data',
473+
body
474+
)
475+
})
472476

473477
const recurseChildren = (children, id, title, parentId) => {
474478
return new Folder({

0 commit comments

Comments
 (0)