patch_detector: refactor

This commit is contained in:
2026-02-28 09:28:13 +01:00
parent fe128c0848
commit ea27a0d6f8

View File

@@ -33,21 +33,19 @@ const CDRAGON_ASSETS = [
main()
async function main() {
const client = await connectToDatabase()
const dbPatch = await getLatestPatchFromDatabase(client)
// In dev mode, get patch from database (the one we have match data for)
if (process.env.NODE_ENV === 'development') {
console.log('Development mode: downloading cache for database patch')
const client = await connectToDatabase()
const dbPatch = await getLatestPatchFromDatabase(client)
await client.close()
if (dbPatch) {
console.log('Latest patch in database: ' + dbPatch)
await downloadAssets(dbPatch)
} else {
console.log('No patch found in database, fetching latest from game...')
const latestPatch = await fetchLatestPatch()
console.log('Latest game patch: ' + latestPatch)
await downloadAssets(latestPatch)
console.log('No patch found in database!')
}
return
}
@@ -55,12 +53,12 @@ async function main() {
// Production mode: check database and update if new patch
const newPatch = await fetchLatestPatch()
console.log('Latest patch is: ' + newPatch)
const client = await connectToDatabase()
const newDate = new Date()
if (!(await compareLatestSavedPatch(client, newPatch, newDate))) {
await downloadAssets(newPatch)
}
await client.close()
}