mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-04-23 08:57:46 -05:00
Fix issues that prevented the Splatfest images from downloading
It was trying to encode the images as JSON and errors were being discarded silently.
This commit is contained in:
parent
bd2b60ddf2
commit
cb11dbfda1
|
|
@ -3,7 +3,7 @@ const mkdirp = require('mkdirp');
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const { readJson, writeJson } = require('../utilities');
|
||||
const { readJson } = require('../utilities');
|
||||
const { languages } = require('../../js/regions');
|
||||
|
||||
class FestivalsUpdater extends Updater {
|
||||
|
|
@ -37,17 +37,17 @@ class FestivalsUpdater extends Updater {
|
|||
this.region = region;
|
||||
}
|
||||
|
||||
writeFile(filename, regionData) {
|
||||
mkdirp(path.dirname(filename));
|
||||
|
||||
processData(regionData) {
|
||||
// Load existing data since we only need to modify this region's data
|
||||
let data = {};
|
||||
let filename = this.getFilename();
|
||||
if (fs.existsSync(filename))
|
||||
data = readJson(filename);
|
||||
|
||||
let region = this.region.toLowerCase();
|
||||
data[region] = JSON.parse(regionData);
|
||||
writeJson(filename, data);
|
||||
data[region] = regionData;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
getLanguages() {
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ class Updater {
|
|||
let dataString = JSON.stringify(data);
|
||||
|
||||
// Write the data to disk
|
||||
let localPath = `${dataPath}/${this.options.filename}`;
|
||||
this.writeFile(localPath, dataString);
|
||||
this.writeFile(this.getFilename(), dataString);
|
||||
|
||||
// Download images if necessary
|
||||
await this.downloadImages(data);
|
||||
|
|
@ -47,6 +46,10 @@ class Updater {
|
|||
this.info('Done.');
|
||||
}
|
||||
|
||||
getFilename() {
|
||||
return `${dataPath}/${this.options.filename}`;
|
||||
}
|
||||
|
||||
getData({ region, language }) {
|
||||
let splatnet = new SplatNet(region, language);
|
||||
return this.options.request(splatnet);
|
||||
|
|
@ -168,17 +171,16 @@ class Updater {
|
|||
return;
|
||||
|
||||
// Otherwise, download the image
|
||||
try {
|
||||
this.info(`Downloading image: ${imagePath}`);
|
||||
let splatnet = new SplatNet;
|
||||
let image = await this.handleRequest(splatnet.getImage(imagePath));
|
||||
this.writeFile(localPath, image);
|
||||
this.info(`Downloading image: ${imagePath}`);
|
||||
let splatnet = new SplatNet;
|
||||
let image = await this.handleRequest(splatnet.getImage(imagePath));
|
||||
// console.log(image.length)
|
||||
this.writeFile(localPath, image);
|
||||
|
||||
// Temporary: Also save the file to the old path for now
|
||||
// This allows for old versions of the site to continue downloading images
|
||||
let oldPath = path.resolve('public/assets/img/splatnet') + '/' + path.basename(imagePath);
|
||||
this.writeFile(oldPath, image);
|
||||
} catch (e) { }
|
||||
// Temporary: Also save the file to the old path for now
|
||||
// This allows for old versions of the site to continue downloading images
|
||||
let oldPath = path.resolve('public/assets/img/splatnet') + '/' + path.basename(imagePath);
|
||||
this.writeFile(oldPath, image);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user