From e4018a7008da265b9d642dcb5039ab7eeb2026d2 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 28 Feb 2021 21:31:42 -0600 Subject: actually fix cache --- build/constants.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'build') diff --git a/build/constants.js b/build/constants.js index 5e09240..961e998 100644 --- a/build/constants.js +++ b/build/constants.js @@ -57,6 +57,7 @@ async function fetchFile(path) { sha: data.sha }; fileCache.set(path, file); + return file; } /** * Edit a file on skyblock-constants @@ -65,13 +66,18 @@ async function fetchFile(path) { * @param newContent The new content in the file */ async function editFile(file, message, newContent) { - fileCache.set(file.path, newContent); - await fetchGithubApi('PUT', `/repos/${owner}/${repo}/contents/${file.path}`, { 'Content-Type': 'application/json' }, { + const r = await fetchGithubApi('PUT', `/repos/${owner}/${repo}/contents/${file.path}`, { 'Content-Type': 'application/json' }, { message: message, content: Buffer.from(newContent).toString('base64'), sha: file.sha, branch: 'main' }); + const data = await r.json(); + fileCache.set(file.path, { + path: data.content.path, + content: newContent, + sha: data.content.sha + }); } /** Fetch all the known SkyBlock stats as an array of strings */ async function fetchStats() { -- cgit