Skip to content

bug(storage): TransferManager#downloadManyFiles silently ignores the prefix option #9823

Open

Description

@arjunjaincs

Please make sure you have searched for information in the following guides.

Library Name

@google-cloud/storage

A screenshot that you have tested with "Try this API".

N/A. This is a local path computation bug in the client library, not an API call.

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://gist.github.com/arjunjaincs/9048774649412c2bf12fd66da1a40f96

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

  1. npm i @google-cloud/storage (8.4.0)
  2. Run the gist (file.download is stubbed, no credentials needed)
  3. Observe the destination passed to file.download

A clear and concise description of what the bug is, and what you expected to happen.

DownloadManyFilesOptions.prefix is documented as "A prefix to append to all of the downloaded files", but TransferManager#downloadManyFiles ignores it.

Call: downloadManyFiles([bucket.file('first.txt')], {prefix: 'out-dir'})
Expected: /out-dir/first.txt
Actual: /first.txt

The base directory is computed only from passthroughOptions.destination, so prefix has no effect. This appears to have been dropped when path containment was added in googleapis/nodejs-storage#2654.

The existing test "sets the destination correctly when provided a prefix" passes anyway: its assertions run inside the stubbed file.download, and downloadManyFiles catches errors thrown there and reports the file as skipped.

I have a fix with tests ready and will open a PR.

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

The public option type and docs describe prefix as prepended to downloaded file paths. It worked before path containment was introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the Cloud Storage API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions