Commit 5093f333 authored by nanahira's avatar nanahira

add full

parent b9138d83
Pipeline #39414 passed with stages
in 1 minute and 34 seconds
...@@ -42,15 +42,17 @@ export class UpdateController { ...@@ -42,15 +42,17 @@ export class UpdateController {
@ApiOperation({ summary: '获取 app 完整包 metalink', description: '只包含完整包的' }) @ApiOperation({ summary: '获取 app 完整包 metalink', description: '只包含完整包的' })
@ApiParam({ name: 'id', description: 'APP 的 id' }) @ApiParam({ name: 'id', description: 'APP 的 id' })
@ApiParam({ name: 'version', description: 'APP 的版本号' }) @ApiParam({ name: 'version', description: 'APP 的版本号' })
@ApiParam({ name: 'full', description: '强制使用完整包' })
@ApiOkResponse({ type: String }) @ApiOkResponse({ type: String })
// @Header('Cache-Control', 'public, max-age=31536000, immutable') // @Header('Cache-Control', 'public, max-age=31536000, immutable')
async getFullPackageMetalink( async getFullPackageMetalink(
@Param('id') id: string, @Param('id') id: string,
@Query(new ValidationPipe({ transform: true })) depot: DepotDto, @Query(new ValidationPipe({ transform: true })) depot: DepotDto,
@Param('version') version: string, @Param('version') version: string,
@Ip() ip: string @Ip() ip: string,
@Query('full') full: string | undefined = undefined
) { ) {
return this.updateService.getFullPackageMetalink(id, depot, version, ip); return this.updateService.getFullPackageMetalink(id, depot, version, ip, !!full);
} }
@Get('single/:path') @Get('single/:path')
......
...@@ -158,7 +158,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -158,7 +158,7 @@ export class UpdateService extends ConsoleLogger {
}; };
} }
async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string, ip: string) { async getFullPackageMetalink(id: string, depotDto: DepotDto, version: string, ip: string, full = false) {
const tryRole = (role: ArchiveType, noErrorExit = false) => const tryRole = (role: ArchiveType, noErrorExit = false) =>
this.getArchives( this.getArchives(
id, id,
...@@ -167,7 +167,7 @@ export class UpdateService extends ConsoleLogger { ...@@ -167,7 +167,7 @@ export class UpdateService extends ConsoleLogger {
(qb) => qb.select(['archive.hash', 'archive.path', 'archive.size']).andWhere('archive.role = :role', { role }), (qb) => qb.select(['archive.hash', 'archive.path', 'archive.size']).andWhere('archive.role = :role', { role }),
noErrorExit noErrorExit
); );
let archives = await tryRole(ArchiveType.Fulls, true); let archives = full ? [] : await tryRole(ArchiveType.Fulls, true);
if (!archives.length) { if (!archives.length) {
archives = await tryRole(ArchiveType.Full); archives = await tryRole(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