Skip to content

Commit

Permalink
fix bulk test tool for ALWAYS_COMPRESS mode (#787)
Browse files Browse the repository at this point in the history
* fix bulk test tool for possible compression, regardless of original

* remove unused import
  • Loading branch information
eschultink authored Aug 19, 2024
1 parent e5a723c commit d4b43fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion tools/psoxy-test/lib/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import fs from 'fs';
import getLogger from './logger.js';
import _ from 'lodash';
import zlib from 'node:zlib';


/**
Expand Down Expand Up @@ -292,7 +293,12 @@ async function download(bucket, key, destination, options, client, logger) {

// save file locally
await new Promise((resolve, reject) => {
downloadResponse.Body.pipe(fs.createWriteStream(destination))
let stream = downloadResponse.Body;
if (downloadResponse.ContentEncoding?.toLowerCase() === 'gzip') {
stream = stream.pipe(zlib.createGunzip());
}
stream
.pipe(fs.createWriteStream(destination))
.on('error', err => reject(err))
.on('close', () => resolve())
})
Expand Down
2 changes: 1 addition & 1 deletion tools/psoxy-test/lib/gcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async function download(bucketName, fileName, destination, client, logger) {
}

const downloadFunction = async () => client.bucket(bucketName).file(fileName)
.download({ destination: destination, decompress: false });
.download({ destination: destination, decompress: true });
const onErrorStop = (error) => error.code !== 404;

const downloadResponse = await executeWithRetry(downloadFunction, onErrorStop,
Expand Down
2 changes: 0 additions & 2 deletions tools/psoxy-test/psoxy-test-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ export default async function (options = {}) {
let sanitizedDiffPath = sanitized;
const isOriginalGzipped = await isGzipped(original);
if (isOriginalGzipped) {
// Assume sanitized file is also gzipped
originalDiffPath = await unzip(original);
sanitizedDiffPath = await unzip(sanitized);
}

let diff;
Expand Down

0 comments on commit d4b43fd

Please sign in to comment.