Skip to content

Commit a2303ec

Browse files
committed
adjust resync so it doesn't force a repull of the metadata from igdb if it's current
1 parent 7d431f1 commit a2303ec

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

lib/crawler/metadatamanager.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,37 @@ export default class MetadataManager {
115115
}
116116

117117
async matchAllMetadata(fuzzy = false) {
118-
let games = await File.findAll({
119-
where: {
120-
nongame: false,
121-
detailsId: null,
122-
},
123-
attributes: ["id", "filename", "category"],
124-
order: ["id", "filename"],
125-
include: { model: Metadata, as: "details" },
126-
});
118+
let games = [];
119+
if (process.env.FORCE_METADATA_RESYNC == "1") {
120+
games = await File.findAll({
121+
where: {
122+
nongame: false,
123+
},
124+
attributes: ["id", "filename", "category"],
125+
order: ["id", "filename"],
126+
include: { model: Metadata, as: "details" },
127+
});
128+
} else {
129+
games = await File.findAll({
130+
where: {
131+
nongame: false,
132+
detailsId: null,
133+
},
134+
attributes: ["id", "filename", "category"],
135+
order: ["id", "filename"],
136+
include: { model: Metadata, as: "details" },
137+
});
138+
}
139+
127140
let count = games.length;
128141
let timer = new Timer();
129142
let found = 0;
130143
console.log(`Matching ${count} games to metadata.`);
131144
for (let x = 0; x < count; x++) {
132145
singleLineStatus(
133-
`Matching metadata: ${x} / ${count} ${(
134-
((x) / count) *
135-
100
136-
).toFixed(2)}% (${timer.elapsed()}) Total Matches: ${found}`
146+
`Matching metadata: ${x} / ${count} ${((x / count) * 100).toFixed(
147+
2
148+
)}% (${timer.elapsed()}) Total Matches: ${found}`
137149
);
138150
let game = games[x];
139151
let metadata = await Metadata.searchByText(

server.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ async function getFilesJob() {
115115

116116
async function updateMetadata() {
117117
if (updatingFiles) return;
118-
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount()) || process.env.FORCE_METADATA_RESYNC == "1") {
118+
let updateMatches = process.env.FORCE_METADATA_RESYNC == "1" ? true : false
119+
if ((await Metadata.count()) < (await metadataManager.getIGDBGamesCount())) {
119120
await metadataManager.syncAllMetadata();
121+
updateMatches = true;
122+
}
123+
if(updateMatches){
120124
if (await Metadata.count()) {
121125
await metadataManager.matchAllMetadata();
122126
}

0 commit comments

Comments
 (0)