Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecated directory. prefix should be used instead #1370

Merged
merged 4 commits into from Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/bucket.ts
Expand Up @@ -113,6 +113,7 @@ export interface EnableLoggingOptions {
export interface GetFilesOptions {
autoPaginate?: boolean;
delimiter?: string;
/** @deprecated */
directory?: string;
endOffset?: string;
includeTrailingDelimiter?: boolean;
Expand Down Expand Up @@ -2195,8 +2196,8 @@ class Bucket extends ServiceObject {
* names, aside from the prefix, contain delimiter will have their name
* truncated after the delimiter, returned in `apiResponse.prefixes`.
* Duplicate prefixes are omitted.
* @property {string} [directory] Filter results based on a directory name, or
* more technically, a "prefix".
* @deprecated @property {string} [directory] Filter results based on a directory name, or
* more technically, a "prefix". Assumes delimeter to be '/'. Deprecated. Use prefix instead.
* @property {string} [endOffset] Filter results to objects whose names are
* lexicographically before endOffset. If startOffset is also set, the objects
* listed have names between startOffset (inclusive) and endOffset (exclusive).
Expand Down Expand Up @@ -2235,8 +2236,8 @@ class Bucket extends ServiceObject {
* names, aside from the prefix, contain delimiter will have their name
* truncated after the delimiter, returned in `apiResponse.prefixes`.
* Duplicate prefixes are omitted.
* @param {string} [query.directory] Filter results based on a directory name, or
* more technically, a "prefix".
* @deprecated @param {string} [query.directory] Filter results based on a directory name, or
* more technically, a "prefix". Assumes delimeter to be '/'. Deprecated. Use query.prefix instead.
* @param {string} [query.endOffset] Filter results to objects whose names are
* lexicographically before endOffset. If startOffset is also set, the objects
* listed have names between startOffset (inclusive) and endOffset (exclusive).
Expand Down
2 changes: 2 additions & 0 deletions system-test/storage.ts
Expand Up @@ -3150,6 +3150,7 @@ describe('storage', () => {
});

it('should get files from a directory', done => {
//Note: Directory is deprecated.
bucket.getFiles({directory: DIRECTORY_NAME}, (err, files) => {
assert.ifError(err);
assert.strictEqual(files!.length, 3);
Expand All @@ -3158,6 +3159,7 @@ describe('storage', () => {
});

it('should get files from a directory as a stream', done => {
//Note: Directory is deprecated.
let numFilesEmitted = 0;

bucket
Expand Down
2 changes: 2 additions & 0 deletions test/bucket.ts
Expand Up @@ -1478,6 +1478,7 @@ describe('Bucket', () => {
});

it('should allow setting a directory', done => {
//Note: Directory is deprecated.
const directory = 'directory-name';
bucket.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.qs.prefix, `${directory}/`);
Expand All @@ -1488,6 +1489,7 @@ describe('Bucket', () => {
});

it('should strip excess slashes from a directory', done => {
//Note: Directory is deprecated.
const directory = 'directory-name///';
bucket.request = (reqOpts: DecorateRequestOptions) => {
assert.strictEqual(reqOpts.qs.prefix, 'directory-name/');
Expand Down