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 --- src/constants.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/constants.ts b/src/constants.ts index 1792b94..610d1a8 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -72,6 +72,7 @@ async function fetchFile(path: string): Promise { sha: data.sha } fileCache.set(path, file) + return file } /** @@ -81,8 +82,7 @@ async function fetchFile(path: string): Promise { * @param newContent The new content in the file */ async function editFile(file: GithubFile, message: string, newContent: string) { - fileCache.set(file.path, newContent) - await fetchGithubApi( + const r = await fetchGithubApi( 'PUT', `/repos/${owner}/${repo}/contents/${file.path}`, { 'Content-Type': 'application/json' }, @@ -93,6 +93,12 @@ async function editFile(file: GithubFile, message: string, newContent: string) { 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 */ -- cgit