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 {
@ApiOperation({ summary: '获取 app 完整包 metalink', description: '只包含完整包的' })
@ApiParam({ name: 'id', description: 'APP 的 id' })
@ApiParam({ name: 'version', description: 'APP 的版本号' })
@ApiParam({ name: 'full', description: '强制使用完整包' })
@ApiOkResponse({ type: String })
// @Header('Cache-Control', 'public, max-age=31536000, immutable')
async getFullPackageMetalink(
@Param('id') id: string,
@Query(new ValidationPipe({ transform: true })) depot: DepotDto,
@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')
......
......@@ -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) =>
this.getArchives(
id,
......@@ -167,7 +167,7 @@ export class UpdateService extends ConsoleLogger {
(qb) => qb.select(['archive.hash', 'archive.path', 'archive.size']).andWhere('archive.role = :role', { role }),
noErrorExit
);
let archives = await tryRole(ArchiveType.Fulls, true);
let archives = full ? [] : await tryRole(ArchiveType.Fulls, true);
if (!archives.length) {
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