Commit 06c3388d authored by nanahira's avatar nanahira

add test interface

parent 1286459a
Pipeline #17484 passed with stages
in 2 minutes and 21 seconds
......@@ -48,12 +48,20 @@ export class UpdateController {
@Param('id') id: string,
@Query(new ValidationPipe({ transform: true })) depot: DepotDto,
@Param('version') version: string,
@Res({ passthrough: true }) res: Response,
@Ip() ip: string
) {
return this.updateService.getFullPackageMetalink(id, depot, version, ip);
}
@Get('single/:path')
@Render('metalinks')
@ApiOperation({ summary: '获取单个包 metalink', description: '测试使用' })
@ApiParam({ name: 'path', description: '路径' })
@ApiOkResponse({ type: String })
async getSinglePackageMetalink(@Param('path') path: string, @Ip() ip: string) {
return this.updateService.getSinglePackageMetalink(path, ip);
}
@Post('update/:id/:version')
@Render('metalinks')
@ApiOperation({ summary: '获取 app 部分包 metalink', description: '根据文件返回需要下载什么文件' })
......
......@@ -138,6 +138,21 @@ export class UpdateService extends ConsoleLogger {
};
}
async getSinglePackageMetalink(path: string, ip: string) {
const archives = await this.db.getRepository(Archive).find({
where: { path },
select: ['hash', 'path', 'size'],
});
if (!archives.length) {
throw new BlankReturnMessageDto(404, 'Archive not found').toException();
}
await this.mirror.lookForArchivesMirror(archives, ip);
return {
cdnUrl: this.cdnUrl,
archives,
};
}
async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string, ip: string) {
const archives = await this.getArchives(id, depotDto, version, (qb) =>
qb.select(['archive.hash', 'archive.path', 'archive.size']).andWhere('archive.role = :fullRole', { fullRole: ArchiveType.Full })
......
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