Commit 330faac5 authored by nanahira's avatar nanahira

add cdnUrLCn

parent 955068fb
Pipeline #39492 passed with stages
in 3 minutes and 42 seconds
...@@ -41,6 +41,7 @@ export class S3Service extends ConsoleLogger { ...@@ -41,6 +41,7 @@ export class S3Service extends ConsoleLogger {
public readonly cdnUrl = public readonly cdnUrl =
this.getConfig('S3_CDN_URL') || `${this.getConfig('S3_ENDPOINT')}/${this.bucket}${this.prefix ? `/${this.prefix}` : ''}`; this.getConfig('S3_CDN_URL') || `${this.getConfig('S3_ENDPOINT')}/${this.bucket}${this.prefix ? `/${this.prefix}` : ''}`;
public readonly cdnUrlOversize = this.getConfig('S3_CDN_URL_OVERSIZE') || this.cdnUrl; public readonly cdnUrlOversize = this.getConfig('S3_CDN_URL_OVERSIZE') || this.cdnUrl;
public readonly cdNUrlCn = this.getConfig('S3_CDN_URL_CN') || this.cdnUrl;
private readonly s3Config: S3ClientConfig = { private readonly s3Config: S3ClientConfig = {
credentials: { credentials: {
accessKeyId: this.getConfig('S3_KEY'), accessKeyId: this.getConfig('S3_KEY'),
......
...@@ -16,18 +16,17 @@ import { ChnrouteService } from '../chnroute/chnroute.service'; ...@@ -16,18 +16,17 @@ import { ChnrouteService } from '../chnroute/chnroute.service';
@Injectable() @Injectable()
export class UpdateService extends ConsoleLogger { export class UpdateService extends ConsoleLogger {
private readonly cdnUrl: string; private readonly cdnUrl = this.packageS3.cdnUrl;
private readonly cdnUrlOversize: string; private readonly cdnUrlOversize = this.packageS3.cdnUrlOversize;
private readonly cdNUrlCn = this.packageS3.cdNUrlCn;
constructor( constructor(
@InjectConnection('app') @InjectConnection('app')
private db: Connection, private db: Connection,
packageS3: PackageS3Service, private packageS3: PackageS3Service,
private mirror: MirrorService, private mirror: MirrorService,
private chnroute: ChnrouteService private chnroute: ChnrouteService
) { ) {
super('update'); super('update');
this.cdnUrl = packageS3.cdnUrl;
this.cdnUrlOversize = packageS3.cdnUrlOversize;
} }
async getAppsJson() { async getAppsJson() {
...@@ -146,8 +145,8 @@ export class UpdateService extends ConsoleLogger { ...@@ -146,8 +145,8 @@ export class UpdateService extends ConsoleLogger {
private async prepareUrl(archives: Archive[], ip: string) { private async prepareUrl(archives: Archive[], ip: string) {
await this.mirror.lookForArchivesMirror(archives, ip); await this.mirror.lookForArchivesMirror(archives, ip);
// const isChina = this.chnroute.isChina(ip); const isChina = this.chnroute.isChina(ip);
archives.forEach((a) => a.fillUrl(this.cdnUrl, this.cdnUrlOversize, false)); archives.forEach((a) => a.fillUrl(isChina ? this.cdNUrlCn : this.cdnUrl, this.cdnUrlOversize, false));
return archives; return archives;
} }
......
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