🐞 fix(录像): 修复录像存储以及读取路径
This commit is contained in:
@@ -361,7 +361,7 @@ export class LadderHandler {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
list: list.map(rec => {
|
||||
const { roleId1, battleCode, hasRpl, remoteUrl } = rec;
|
||||
const rplFileUrl = battleCode && hasRpl ? getRemoteRplFilePath(remoteUrl, roleId1, WAR_TYPE.LADDER, battleCode) : '';
|
||||
const rplFileUrl = battleCode && hasRpl ? remoteUrl : '';
|
||||
return { ...rec, rplFileUrl };
|
||||
}),
|
||||
rplPrefixUrl: getRemoteRplPrefix(pinus.app.get('env'))
|
||||
|
||||
@@ -619,7 +619,7 @@ export class PvpHandler {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
list: pvpRecords.map(rec => {
|
||||
const { roleId1, battleCode, hasRpl, remoteUrl } = rec;
|
||||
const rplFileUrl = battleCode && hasRpl ? getRemoteRplFilePath(remoteUrl, roleId1, WAR_TYPE.PVP, battleCode) : '';
|
||||
const rplFileUrl = battleCode && hasRpl ? remoteUrl : '';
|
||||
return { ...rec, rplFileUrl };
|
||||
}),
|
||||
rplPrefixUrl: getRemoteRplPrefix(pinus.app.get('env'))
|
||||
|
||||
@@ -396,7 +396,7 @@ export class GVGProduceHandler {
|
||||
let result: (GVGVestigeRecUpdate & {rplFileUrl: string})[] = [];
|
||||
for(let rec of list) {
|
||||
const { attackRoleId, battleCode, hasRpl, remoteUrl } = rec;
|
||||
const rplFileUrl = battleCode && hasRpl ? getRemoteRplFilePath(remoteUrl, attackRoleId, WAR_TYPE.GVG_VESTIGE, battleCode) : '';
|
||||
const rplFileUrl = battleCode && hasRpl ? remoteUrl : '';
|
||||
const obj = getVestigeRecStatus(rec);
|
||||
if(obj.status == VESTIGE_STATUS.COMPLETE) result.push({ ...rec, endTime: obj.time, rplFileUrl });
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export default class GVGVestigeRec extends BaseModel {
|
||||
let recs: GVGVestigeRecType[] = await GVGVestigeRecModel.find({
|
||||
vestigeId, $or: [{attackRoleId: roleId}, { defenseRoleId: roleId }],
|
||||
createdAt: { $gte: <Date>getTimeFunD().getBeforeDayWithHour(3) },
|
||||
}).select({ battleCode: 1, attackRoleId: 1, defenseRoleId: 1, _id: 0, endTime: 1, attackInfo: 1, defenseInfo: 1, hasRpl: 1 }).limit(1000).lean();
|
||||
}).select({ battleCode: 1, attackRoleId: 1, defenseRoleId: 1, _id: 0, endTime: 1, attackInfo: 1, defenseInfo: 1, hasRpl: 1, remoteUrl: 1 }).limit(1000).lean();
|
||||
return recs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export default class LadderMatchRec extends BaseModel {
|
||||
endTime: { $gt: startMs },
|
||||
$or: [{roleId1: roleId}, { roleId2: roleId }],
|
||||
status: LADDER_STATUS.COMPLETE
|
||||
}).select({ battleCode: 1, roleId1: 1, roleId2: 1, _id: -1, endTime: 1, attackInfo: 1, defenseInfo: 1, hasRpl: 1 }).limit(1000).lean();
|
||||
}).select({ battleCode: 1, roleId1: 1, roleId2: 1, _id: -1, endTime: 1, attackInfo: 1, defenseInfo: 1, hasRpl: 1, remoteUrl: 1 }).limit(1000).lean();
|
||||
return recs;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ export function getLocalRplUrl(roleId: string, warType: number, battleCode: stri
|
||||
return writePath;
|
||||
}
|
||||
|
||||
export function getRemoteRplUrl(env: string, sshHost: string, roleId: string, warType: number, battleCode: string) {
|
||||
export function getRemoteRplUrl(sshHost: string, roleId: string, warType: number, battleCode: string) {
|
||||
const battleClass = modStr(battleCode, BATTLE_CLASS_MOD); // 将存档文件按一定规则分批保存
|
||||
const rplUrl = `${getPrefixByEnv(env)}/rpls/${md5(sshHost).substring(0, 4)}/${roleId}/${warType}/${battleClass}`;
|
||||
const rplUrl = `/${md5(sshHost).substring(0, 4)}/${roleId}/${warType}/${battleClass}`;
|
||||
return rplUrl;
|
||||
}
|
||||
|
||||
export function getRemoteRplPrefix(env: string) {
|
||||
const rplUrl = `${getPrefixByEnv(env)}/rpls/${md5(env).substring(0, 4)}`;
|
||||
const rplUrl = `${getPrefixByEnv(env)}/rpls/`;
|
||||
return rplUrl;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import { RedisClient } from 'redis';
|
||||
import { REDIS_KEY } from '@consts';
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { getRandEelmWithWeight } from 'app/pubUtils/util';
|
||||
import { getLocalRplUrl, getRemoteRplUrl } from 'app/pubUtils/battleUtils'
|
||||
import { getLocalRplUrl, getRemoteRplUrl, getRemoteRplPrefix } from 'app/pubUtils/battleUtils'
|
||||
import { ChannelInfoModel } from '@db/ChannelInfo';
|
||||
import { GVGVestigeRecModel } from '@db/GVGVestigeRec';
|
||||
import { GVGBattleRecModel } from '@db/GVGBattleRec';
|
||||
@@ -202,7 +202,7 @@ export default class GameController extends Controller {
|
||||
const { ctx } = this;
|
||||
const parts = ctx.multipart();
|
||||
let part;
|
||||
let [writePath, token, battleCode, fullPath, remoteUrl, warType] = ['', '', '', '', '', 0];
|
||||
let [writePath, token, battleCode, fullPath, remoteUrl, warType, prefix] = ['', '', '', '', '', 0, ''];
|
||||
while ((part = await parts()) != null) {
|
||||
if (part.length) {
|
||||
console.log('kv: ', `${part[0]}: ${part[1]}`);
|
||||
@@ -267,7 +267,8 @@ export default class GameController extends Controller {
|
||||
const writeStream = fs.createWriteStream(fullPath);
|
||||
await pump(part, writeStream);
|
||||
|
||||
remoteUrl = `${getRemoteRplUrl(ctx.app.config.realEnv, ctx.app.config.sshHost,roleId, warType, battleCode)}/${battleCode}.bin`;
|
||||
prefix = getRemoteRplPrefix(ctx.app.config.realEnv);
|
||||
remoteUrl = `${getRemoteRplUrl(ctx.app.config.sshHost,roleId, warType, battleCode)}/${battleCode}.bin`;
|
||||
let updateDBRes;
|
||||
if (warType === WAR_TYPE.PVP) {
|
||||
updateDBRes = await PvpRecordModel.updateRplStatus(battleCode, true, remoteUrl);
|
||||
@@ -284,7 +285,7 @@ export default class GameController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { rplUrl: remoteUrl });
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { rplUrl: prefix + remoteUrl });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user