Skip to content

Commit

Permalink
gzip download bug
Browse files Browse the repository at this point in the history
  • Loading branch information
asgray committed Nov 29, 2023
1 parent cd4177b commit d5da96b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions services/FamiliesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d5da96b

Please sign in to comment.