Small fixes (#141)

* fix: save task as Json rather than string

* fix: pull objects before creating game in database

* fix: strips relative dirs from version information

* fix: #132

* fix: lint

* fix: news object ids and small tweaks

* fix: notification styling errors

* fix: lint
This commit is contained in:
DecDuck
2025-07-20 14:56:15 +10:00
committed by GitHub
parent 661dcf86a8
commit 45848d175e
14 changed files with 57 additions and 91 deletions

View File

@ -51,7 +51,7 @@ export default defineEventHandler(async (h3) => {
tags: parsedTags,
...(imageId && { image: imageId }),
...(imageId && { imageObjectId: imageId }),
authorId: "system",
});

View File

@ -147,14 +147,14 @@ class LibraryManager {
}> = [];
const files = await library.versionReaddir(game.libraryPath, versionName);
for (const file of files) {
const filename = path.basename(file);
const dotLocation = file.lastIndexOf(".");
const ext = dotLocation == -1 ? "" : file.slice(dotLocation);
for (const filename of files) {
const basename = path.basename(filename);
const dotLocation = filename.lastIndexOf(".");
const ext = dotLocation == -1 ? "" : filename.slice(dotLocation);
for (const [platform, checkExts] of Object.entries(fileExts)) {
for (const checkExt of checkExts) {
if (checkExt != ext) continue;
const fuzzyValue = fuzzy(filename, game.mName);
const fuzzyValue = fuzzy(basename, game.mName);
options.push({
filename,
platform,

View File

@ -197,8 +197,8 @@ export class MetadataHandler {
{},
["internal:read"],
wrapTaskContext(context, {
min: 63,
max: 100,
min: 60,
max: 95,
prefix: "[object import] ",
}),
);
@ -227,6 +227,13 @@ export class MetadataHandler {
context?.progress(60);
logger.info(`Successfully fetched all metadata.`);
logger.info(`Importing objects...`);
await pullObjects();
progress(95);
await prisma.game.create({
data: {
id: gameId,
@ -262,12 +269,6 @@ export class MetadataHandler {
},
});
progress(63);
logger.info(`Successfully fetched all metadata.`);
logger.info(`Importing objects...`);
await pullObjects();
logger.info(`Finished game import.`);
},
});

View File

@ -8,7 +8,7 @@ class NewsManager {
description: string;
tags: string[];
authorId: string;
image?: string;
imageObjectId?: string;
}) {
return await prisma.article.create({
data: {
@ -23,7 +23,7 @@ class NewsManager {
})),
},
...(data.image && { image: data.image }),
...(data.imageObjectId && { imageObjectId: data.imageObjectId }),
author: {
connect: {
id: data.authorId,

View File

@ -72,7 +72,7 @@ class TaskHandler {
this.taskCreators.set(task.taskGroup, task.build);
}
create(task: Task) {
async create(task: Task) {
let updateCollectTimeout: NodeJS.Timeout | undefined;
let updateCollectResolves: Array<(value: unknown) => void> = [];
let logOffset: number = 0;
@ -131,44 +131,6 @@ class TaskHandler {
const taskPool = this.taskPool;
// Create a pino transport that replicates the old log function behavior
// const taskLogger = pino({
// hooks: {
// logMethod(args, method) {
// // Combine all arguments into a single string message
// const message = args.map(String).join(" ");
// const now = new Date();
// const pad = (n: number, width = 2) =>
// n.toString().padStart(width, "0");
// const year = now.getUTCFullYear();
// const month = pad(now.getUTCMonth() + 1);
// const day = pad(now.getUTCDate());
// const hours = pad(now.getUTCHours());
// const minutes = pad(now.getUTCMinutes());
// const seconds = pad(now.getUTCSeconds());
// const milliseconds = pad(now.getUTCMilliseconds(), 3);
// const logObj = {
// timestamp: `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds} UTC`,
// message,
// };
// // Push the formatted log string to the task's log array
// const taskEntry = taskPool.get(task.id);
// if (taskEntry) {
// taskEntry.log.push(JSON.stringify(logObj));
// updateAllClients();
// }
// // Optionally, still call the original method if you want logs elsewhere
// method.apply(this, args);
// },
// },
// });
// Custom writable stream to capture logs
const logStream = new Writable({
objectMode: true,
@ -227,7 +189,7 @@ class TaskHandler {
endTime: undefined,
});
updateAllClients(true);
await updateAllClients(true);
droplet.callAltThreadFunc(async () => {
const taskEntry = this.taskPool.get(task.id);
@ -267,9 +229,7 @@ class TaskHandler {
acls: taskEntry.acls,
...(taskEntry.error
? { error: JSON.stringify(taskEntry.error) }
: undefined),
...(taskEntry.error ? { error: taskEntry.error } : undefined),
},
});