Skip to content

Commit

Permalink
fix: deprecated directory. prefix should be used instead (#1370)
Browse files Browse the repository at this point in the history
* fix: deprecated directory. prefix should be used instead

* responded to comments
  • Loading branch information
shaffeeullah committed Jan 11, 2021
1 parent 2569510 commit fae4c06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit fae4c06

Please sign in to comment.