fix(npfl): Query files from FileCTR

Also use proper size on content size column.
This commit is contained in:
Daniel López Guimaraes
2025-11-01 12:11:14 +00:00
parent 3bf0334c0c
commit 3a55e46fa1
2 changed files with 13 additions and 13 deletions

View File

@@ -130,10 +130,10 @@ export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID
return FileWUP.find(filter);
}
export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, attribute1?: string, attribute2?: string, attribute3?: string): Promise<HydratedFileWUPDocument[]> {
export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, attribute1?: string, attribute2?: string, attribute3?: string): Promise<HydratedFileCTRDocument[]> {
verifyConnected();
const filter: mongoose.FilterQuery<IFileWUP> = {
const filter: mongoose.FilterQuery<IFileCTR> = {
task_id: taskID.slice(0, 7),
boss_app_id: bossAppID,
$and: []
@@ -162,22 +162,22 @@ export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID:
}
if (attribute1) {
filter.attribute1 = attribute1;
filter.attributes.attribute1 = attribute1;
}
if (attribute2) {
filter.attribute2 = attribute2;
filter.attributes.attribute2 = attribute2;
}
if (attribute3) {
filter.attribute3 = attribute3;
filter.attributes.attribute3 = attribute3;
}
if (filter.$and?.length === 0) {
delete filter.$and;
}
return FileWUP.find(filter);
return FileCTR.find(filter);
}
export function getCTRTaskFile(bossAppID: string, taskID: string, name: string, country?: string, language?: string): Promise<HydratedFileCTRDocument | null> {

View File

@@ -55,11 +55,11 @@ npfl.get('/p01/filelist/:appID/:taskID', async (request: express.Request<{
// * File lines have the following fields:
// *
// * - File name
// * - Unknown (password?)
// * - Description
// * - Attribute 1
// * - Attribute 2
// * - Attribute 3
// * - File size (0 is allowed)
// * - Content size (size of the first payload content)
// * - Updated time (seconds)
// *
// * All fields of a file line are separated by a tab (\t) and are present even if no value.
@@ -83,11 +83,11 @@ npfl.get('/p01/filelist/:appID/:taskID', async (request: express.Request<{
for (const file of files) {
const params = [
file.name,
file.password, // * Unsure if this is really what this is for. Team Kirby Clash Deluxe uses this for passwords though
file.attribute1,
file.attribute2,
file.attribute3,
file.size,
file.attributes.description,
file.attributes.attribute1,
file.attributes.attribute2,
file.attributes.attribute3,
file.payload_contents[0]?.size ?? 0,
file.updated / 1000n // * Expects time as seconds, not milliseconds
];
const line = `${params.join('\t')}\r\n`;