Commit 0caef458 authored by nanahira's avatar nanahira

build exists => 201

parent ce55d460
Pipeline #23568 failed with stages
in 2 minutes and 20 seconds
......@@ -196,7 +196,7 @@ export class AppService extends ConsoleLogger {
}
const depot = await this.getOrCreateDepot(app, depotDto);
if (await this.checkExistingBuild(depot, version)) {
throw new BlankReturnMessageDto(404, 'Build exists').toException();
throw new BlankReturnMessageDto(201, 'Build exists').toException();
}
let build = new Build();
build.depot = depot;
......
import { InjectRedis, Redis } from '@nestjs-modules/ioredis';
import { Injectable } from '@nestjs/common';
import Redlock from '@nanahira/redlock';
import { ConfigService } from '@nestjs/config';
import Redis from 'ioredis';
@Injectable()
export class LockService extends Redlock {
constructor(@InjectRedis() private readonly redis: Redis) {
super([redis]);
export class LockService {
constructor(private config: ConfigService) { }
getLockInstance() {
const url = this.config.get<string>('REDIS_URL');
const redis = new Redis(url);
return new Redlock([redis]);
}
}
......@@ -185,7 +185,7 @@ export class MirrorService extends ConsoleLogger implements OnApplicationBootstr
if (!middleware.singleton) {
return this.uploadWithMiddlewareProcess(uploadInfo, middleware);
}
return this.redlock.using([`mirror:${middleware.identifier}`], 5000, () => this.uploadWithMiddlewareProcess(uploadInfo, middleware));
return this.redlock.getLockInstance().using([`mirror:${middleware.identifier}`], 5000, () => this.uploadWithMiddlewareProcess(uploadInfo, middleware));
}
async uploadWithRandomMiddleware(uploadInfo: UploadInfo, middlewares = Array.from(this.middlewares.values())) {
......
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