adjust resync so it doesn't force a repull of the metadata from igdb if it's current

This commit is contained in:
Alexandra
2025-05-31 17:30:49 -06:00
parent 7d431f1727
commit a2303ec684
2 changed files with 30 additions and 14 deletions

View File

@@ -115,25 +115,37 @@ export default class MetadataManager {
}
async matchAllMetadata(fuzzy = false) {
let games = await File.findAll({
where: {
nongame: false,
detailsId: null,
},
attributes: ["id", "filename", "category"],
order: ["id", "filename"],
include: { model: Metadata, as: "details" },
});
let games = [];
if (process.env.FORCE_METADATA_RESYNC == "1") {
games = await File.findAll({
where: {
nongame: false,
},
attributes: ["id", "filename", "category"],
order: ["id", "filename"],
include: { model: Metadata, as: "details" },
});
} else {
games = await File.findAll({
where: {
nongame: false,
detailsId: null,
},
attributes: ["id", "filename", "category"],
order: ["id", "filename"],
include: { model: Metadata, as: "details" },
});
}
let count = games.length;
let timer = new Timer();
let found = 0;
console.log(`Matching ${count} games to metadata.`);
for (let x = 0; x < count; x++) {
singleLineStatus(
`Matching metadata: ${x} / ${count} ${(
((x) / count) *
100
).toFixed(2)}% (${timer.elapsed()}) Total Matches: ${found}`
`Matching metadata: ${x} / ${count} ${((x / count) * 100).toFixed(
2
)}% (${timer.elapsed()}) Total Matches: ${found}`
);
let game = games[x];
let metadata = await Metadata.searchByText(

View File

@@ -115,8 +115,12 @@ async function getFilesJob() {
async function updateMetadata() {
if (updatingFiles) return;
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount()) || process.env.FORCE_METADATA_RESYNC == "1") {
let updateMatches = process.env.FORCE_METADATA_RESYNC == "1" ? true : false
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount())) {
await metadataManager.syncAllMetadata();
updateMatches = true;
}
if(updateMatches){
if (await Metadata.count()) {
await metadataManager.matchAllMetadata();
}