patch_detector: refactor
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user