-
-
Notifications
You must be signed in to change notification settings - Fork 54
Add 'downloadWaitTime' setting #274
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -77,7 +77,7 @@ export class Video extends Attachment { | |||||||||||||||||||||||||
| private static readonly MaxRetries = 1; | ||||||||||||||||||||||||||
| private static readonly DownloadThreads = 8; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private static readonly DownloadSemaphore = new Semaphore(this.DownloadThreads); | ||||||||||||||||||||||||||
| private static readonly DownloadSemaphore = new Semaphore(settings.downloadWaitTime > 0 ? 1 : this.DownloadThreads); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private static readonly ThrottleOptions: ThrottleOptions = { rate: settings.maxDownloadSpeed * byteToMbits }; | ||||||||||||||||||||||||||
| private static readonly ThrottleGroup = settings.maxDownloadSpeed > -1 ? new ThrottleGroup(Video.ThrottleOptions) : undefined; | ||||||||||||||||||||||||||
|
|
@@ -155,6 +155,10 @@ export class Video extends Attachment { | |||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||
| release(); | ||||||||||||||||||||||||||
| promQueued.dec(); | ||||||||||||||||||||||||||
| // Wait between downloads if downloadWaitTime is set | ||||||||||||||||||||||||||
| if (settings.downloadWaitTime > 0) { | ||||||||||||||||||||||||||
| await sleep(settings.downloadWaitTime * 1000); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
156
to
+161
|
||||||||||||||||||||||||||
| release(); | |
| promQueued.dec(); | |
| // Wait between downloads if downloadWaitTime is set | |
| if (settings.downloadWaitTime > 0) { | |
| await sleep(settings.downloadWaitTime * 1000); | |
| } | |
| // Wait between downloads if downloadWaitTime is set | |
| if (settings.downloadWaitTime > 0) { | |
| await sleep(settings.downloadWaitTime * 1000); | |
| } | |
| release(); | |
| promQueued.dec(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DownloadSemaphore is initialized at class load time using a static field, which means settings.downloadWaitTime is only read once when the class is first loaded. If the setting is changed at runtime (which appears to be supported by the @inrixia/db library with updateOnExternalChanges: true), the semaphore won't be reconfigured.
Consider either: (1) making this check dynamic rather than static initialization, or (2) documenting that changes to downloadWaitTime require a restart to take effect.