Skip to content

feat(storage): add compose file sample with deleteSourceObjects - #4359

Closed
nidhiii-27 wants to merge 1 commit into
mainfrom
compose-delete-source-objects-node
Closed

feat(storage): add compose file sample with deleteSourceObjects#4359
nidhiii-27 wants to merge 1 commit into
mainfrom
compose-delete-source-objects-node

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Add composeFile.js sample and its corresponding tests in system-test/files.test.js.

Add composeFile.js sample and its corresponding tests in system-test/files.test.js.

[Generated-by: AI]
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Jun 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new script storage/composeFile.js to compose multiple files in a Google Cloud Storage bucket, along with corresponding system tests in storage/system-test/files.test.js. Feedback on the changes suggests improving the robustness of command-line argument parsing by converting the boolean string to lowercase, and optimizing the test cleanup phase by deleting temporary files in parallel using Promise.all.

Comment thread storage/composeFile.js

async function composeFile() {
// If deleteSourceObjects is passed as a string from command line, parse it
const shouldDelete = String(deleteSourceObjects) === 'true';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make the command-line argument parsing more robust, consider converting the string representation of deleteSourceObjects to lowercase. This ensures that inputs like 'TRUE' or 'True' are correctly parsed as true.

Suggested change
const shouldDelete = String(deleteSourceObjects) === 'true';
const shouldDelete = String(deleteSourceObjects).toLowerCase() === 'true';

Comment on lines +168 to +181
afterEach(async () => {
await bucket
.file(firstFile)
.delete()
.catch(() => {});
await bucket
.file(secondFile)
.delete()
.catch(() => {});
await bucket
.file(destinationFile)
.delete()
.catch(() => {});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve test execution speed, perform the cleanup of the source and destination files in parallel using Promise.all instead of sequentially awaiting each deletion.

    afterEach(async () => {
      await Promise.all([
        bucket.file(firstFile).delete().catch(() => {}),
        bucket.file(secondFile).delete().catch(() => {}),
        bucket.file(destinationFile).delete().catch(() => {}),
      ]);
    });

@nidhiii-27 nidhiii-27 closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant