From d5da96b5e441bfdb429bdcd56ea86016e6374874 Mon Sep 17 00:00:00 2001 From: asgray Date: Tue, 28 Nov 2023 17:26:46 -0800 Subject: [PATCH] gzip download bug --- services/FamiliesService.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/FamiliesService.js b/services/FamiliesService.js index b0d0b81..ffb5883 100644 --- a/services/FamiliesService.js +++ b/services/FamiliesService.js @@ -314,20 +314,19 @@ const readFamilies = ({...args} = {}, { format, sort, name, name_prefix, name_ac let b64 = Buffer.from(compressed).toString('base64') formatted.body = b64 - // write object to string - let str = JSON.stringify(formatted) - // If large request write data to working file and rename to finished file if (total_count > config.CACHE_CUTOFF && fs.existsSync(working_file)) { + // write object to string + let str = JSON.stringify(formatted) + //write and rename file fs.writeFileSync(working_file, str) fs.renameSync(working_file, cache_file) + // otherwise, remove placeholder working file } else if (fs.existsSync(working_file)){ fs.unlinkSync(working_file) } - - resolve(Service.successResponse(str, 200)); } resolve(Service.successResponse(formatted, 200));