Skip to content

Commit c32ccfb

Browse files
committed
feat(api): Made maxConcurrent downloads configurable
1 parent 64481cd commit c32ccfb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

apps/api/src/shared/config/config.service.ts

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class ConfigService {
1818
public static readonly DOWNLOAD_LOCATION: string = 'DOWNLOAD_LOCATION'
1919
public static readonly OPENSUBTITLES_USERNAME: string = 'OPENSUBTITLES_USERNAME'
2020
public static readonly OPENSUBTITLES_PASSWORD: string = 'OPENSUBTITLES_PASSWORD'
21+
public static readonly MAX_CONCURRENT_DOWNLOADS: string = 'MAX_CONCURRENT_DOWNLOADS'
2122
public static readonly TRAKT_KEY: string = 'TRAKT_KEY'
2223

2324
private readonly envConfig: { [key: string]: string }
@@ -103,6 +104,8 @@ export class ConfigService {
103104
[ConfigService.OPENSUBTITLES_USERNAME]: Joi.string(),
104105

105106
[ConfigService.OPENSUBTITLES_PASSWORD]: Joi.string()
107+
[ConfigService.MAX_CONCURRENT_DOWNLOADS]: Joi.number()
108+
.default(1),
106109
})
107110

108111
const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true })

apps/api/src/shared/torrent/torrent.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class TorrentService {
3030
/**
3131
* Maximum of concurrent downloads in the background
3232
*/
33-
private maxConcurrent = 1
33+
private readonly maxConcurrent
3434

3535
/**
3636
* Array of downloads that will be downloaded in the background
@@ -89,7 +89,7 @@ export class TorrentService {
8989
private readonly configService: ConfigService,
9090
private readonly subtitlesService: SubtitlesService
9191
) {
92-
this.setupWebTorrent()
92+
this.maxConcurrent = this.configService.get(ConfigService.MAX_CONCURRENT_DOWNLOADS)
9393

9494
// Check for incomplete downloads and add them to the downloads
9595
this.checkForIncompleteDownloads()

0 commit comments

Comments
 (0)