Skip to content

Commit

Permalink
json parse error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
asgray committed Jun 18, 2024
1 parent 899ad0c commit a2df852
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions services/FamiliesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ const readFamilies = ({...args} = {}, { format, sort, name, name_prefix, name_ac
}
else if (
download && (
(!caching && !formatted.body) || // failing to build response body when not caching
(!caching && !formatted.body) && // failing to build response body when not caching
(fs.existsSync(working_file) && !fs.statSync(working_file).size > 0) // cache file exists and is empty
)
) {
Expand Down Expand Up @@ -385,7 +385,7 @@ const readFamilies = ({...args} = {}, { format, sort, name, name_prefix, name_ac
if (caching && fs.existsSync(working_file)) {
logger.info(`Caching ${args_hash}`)
// build JSON header
fs.writeFileSync(cache_file, `"attachment": "families${extensions[format]}", "content_type": "text/plain", "encoding": "identity", "body": "`)
fs.writeFileSync(cache_file, `{"attachment": "families${extensions[format]}", "content_type": "text/plain", "encoding": "identity", "body": "`)
// compress and encode working data into cache file
const zip = await new Promise((resolve, reject) => {
let zipper = child_process.spawn("sh", ["-c", `cat ${working_file} | gzip | base64 -w 0 >> ${cache_file}`]);
Expand Down

0 comments on commit a2df852

Please sign in to comment.