Skip to content

Commit

Permalink
feat: Respect parallel count config
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Oct 21, 2024
1 parent b73b7a2 commit 43d0cdb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ import { isFileSystemFileEntry } from './utils/filesystem.js'
import { Directory } from './utils/fileTree.js'
import { t } from './utils/l10n.js'
import logger from './utils/logger.js'
import { getCapabilities } from '@nextcloud/capabilities'

export enum Status {
IDLE = 0,
UPLOADING = 1,
PAUSED = 2
}

// Maximum number of concurrent uploads
const MAX_CONCURRENCY = 5

export class Uploader {

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

// Global upload queue
private _uploadQueue: Array<Upload> = []
private _jobQueue: PQueue = new PQueue({ concurrency: MAX_CONCURRENCY })
private _jobQueue: PQueue = new PQueue({
// Maximum number of concurrent uploads
// @ts-expect-error TS2339 Object has no defined properties
concurrency: getCapabilities().files?.chunked_upload?.max_parallel_count ?? 5,
})

private _queueSize = 0
private _queueProgress = 0
private _queueStatus: Status = Status.IDLE
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dependencies": {
"@nextcloud/auth": "^2.4.0",
"@nextcloud/axios": "^2.5.1",
"@nextcloud/capabilities": "^1.2.0",
"@nextcloud/dialogs": "^5.3.7",
"@nextcloud/files": "^3.9.0",
"@nextcloud/l10n": "^3.1.0",
Expand Down

0 comments on commit 43d0cdb

Please sign in to comment.