Commit 6c89a95b authored by nanahira's avatar nanahira

fix loop cycle

parent 3bcb5253
Pipeline #17480 passed with stages
in 2 minutes and 39 seconds
import { ConsoleLogger, Injectable } from '@nestjs/common';
import { ConsoleLogger, Injectable, OnApplicationBootstrap } from '@nestjs/common';
import { InjectConnection } from '@nestjs/typeorm';
import { Connection } from 'typeorm';
import { ConfigService } from '@nestjs/config';
......@@ -36,7 +36,7 @@ export interface UploadResult {
}
@Injectable()
export class MirrorService extends ConsoleLogger {
export class MirrorService extends ConsoleLogger implements OnApplicationBootstrap {
private middlewares = new Map<string, Middleware>();
private maximumMirroredSize = 0x7fffffff;
private mirrorConcurrent = this.config.get('MIRROR_CONCURRENT') || 100;
......@@ -49,10 +49,9 @@ export class MirrorService extends ConsoleLogger {
private redlock: LockService
) {
super('mirror');
this.init().then();
}
private async init() {
async onApplicationBootstrap() {
const middlewareUrlStrings = this.config.get<string>('MIRROR_MIDDLEWARES');
if (!middlewareUrlStrings) {
return;
......@@ -153,6 +152,7 @@ export class MirrorService extends ConsoleLogger {
}
this.log(`Saving ${uploadResults.length} mirror records.`);
await this.db.getRepository(ArchiveMirror).save(uploadResults);
return true;
}
private async uploadWithMiddlewareProcess(uploadInfo: UploadInfo, middleware: Middleware): Promise<UploadResult> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment