Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Respect parallel count config #1444

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading