Skip to content

Commit 8783d57

Browse files
committed
feat: Respect parallel count config
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent b73b7a2 commit 8783d57

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

lib/uploader.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ import { isFileSystemFileEntry } from './utils/filesystem.js'
2222
import { Directory } from './utils/fileTree.js'
2323
import { t } from './utils/l10n.js'
2424
import logger from './utils/logger.js'
25+
import { getCapabilities } from '@nextcloud/capabilities'
2526

2627
export enum Status {
2728
IDLE = 0,
2829
UPLOADING = 1,
2930
PAUSED = 2
3031
}
3132

32-
// Maximum number of concurrent uploads
33-
const MAX_CONCURRENCY = 5
34-
3533
export class Uploader {
3634

3735
// Initialized via setter in the constructor
@@ -41,7 +39,12 @@ export class Uploader {
4139

4240
// Global upload queue
4341
private _uploadQueue: Array<Upload> = []
44-
private _jobQueue: PQueue = new PQueue({ concurrency: MAX_CONCURRENCY })
42+
private _jobQueue: PQueue = new PQueue({
43+
// Maximum number of concurrent uploads
44+
// @ts-expect-error TS2339
45+
concurrency: getCapabilities()?.files?.chunked_upload?.max_parallel_count ?? 5,
46+
})
47+
4548
private _queueSize = 0
4649
private _queueProgress = 0
4750
private _queueStatus: Status = Status.IDLE

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"dependencies": {
7777
"@nextcloud/auth": "^2.4.0",
7878
"@nextcloud/axios": "^2.5.1",
79+
"@nextcloud/capabilities": "^1.2.0",
7980
"@nextcloud/dialogs": "^5.3.7",
8081
"@nextcloud/files": "^3.9.0",
8182
"@nextcloud/l10n": "^3.1.0",

0 commit comments

Comments
 (0)