Skip to content

Commit

Permalink
feat(api): Made maxConcurrent downloads configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Oct 12, 2020
1 parent 64481cd commit c32ccfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/api/src/shared/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class ConfigService {
public static readonly DOWNLOAD_LOCATION: string = 'DOWNLOAD_LOCATION'
public static readonly OPENSUBTITLES_USERNAME: string = 'OPENSUBTITLES_USERNAME'
public static readonly OPENSUBTITLES_PASSWORD: string = 'OPENSUBTITLES_PASSWORD'
public static readonly MAX_CONCURRENT_DOWNLOADS: string = 'MAX_CONCURRENT_DOWNLOADS'
public static readonly TRAKT_KEY: string = 'TRAKT_KEY'

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

[ConfigService.OPENSUBTITLES_PASSWORD]: Joi.string()
[ConfigService.MAX_CONCURRENT_DOWNLOADS]: Joi.number()
.default(1),
})

const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true })
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/shared/torrent/torrent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class TorrentService {
/**
* Maximum of concurrent downloads in the background
*/
private maxConcurrent = 1
private readonly maxConcurrent

/**
* Array of downloads that will be downloaded in the background
Expand Down Expand Up @@ -89,7 +89,7 @@ export class TorrentService {
private readonly configService: ConfigService,
private readonly subtitlesService: SubtitlesService
) {
this.setupWebTorrent()
this.maxConcurrent = this.configService.get(ConfigService.MAX_CONCURRENT_DOWNLOADS)

// Check for incomplete downloads and add them to the downloads
this.checkForIncompleteDownloads()
Expand Down

0 comments on commit c32ccfb

Please sign in to comment.