From 6ac93b823966081403e3269adced7a898ffdd4cc Mon Sep 17 00:00:00 2001 From: Sameena Shaffeeullah Date: Wed, 23 Dec 2020 18:19:53 +0000 Subject: [PATCH 1/2] fix: deprecated directory. prefix should be used instead --- src/bucket.ts | 10 +++++----- system-test/storage.ts | 2 ++ test/bucket.ts | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bucket.ts b/src/bucket.ts index 465ef30fb..1c4c6c61c 100644 --- a/src/bucket.ts +++ b/src/bucket.ts @@ -113,7 +113,7 @@ export interface EnableLoggingOptions { export interface GetFilesOptions { autoPaginate?: boolean; delimiter?: string; - directory?: string; + directory?: string; //deprecated endOffset?: string; includeTrailingDelimiter?: boolean; prefix?: string; @@ -2195,8 +2195,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". 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). @@ -2235,8 +2235,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". 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). diff --git a/system-test/storage.ts b/system-test/storage.ts index ad0634f3d..2dfee34f3 100644 --- a/system-test/storage.ts +++ b/system-test/storage.ts @@ -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); @@ -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 diff --git a/test/bucket.ts b/test/bucket.ts index fe30b4e92..d09d8fa43 100644 --- a/test/bucket.ts +++ b/test/bucket.ts @@ -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}/`); @@ -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/'); From 4c2f47d005f983deb70c79209078f4f9bebae74d Mon Sep 17 00:00:00 2001 From: Sameena Shaffeeullah Date: Thu, 7 Jan 2021 19:30:25 +0000 Subject: [PATCH 2/2] responded to comments --- src/bucket.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bucket.ts b/src/bucket.ts index 1c4c6c61c..77ea35bd7 100644 --- a/src/bucket.ts +++ b/src/bucket.ts @@ -113,7 +113,8 @@ export interface EnableLoggingOptions { export interface GetFilesOptions { autoPaginate?: boolean; delimiter?: string; - directory?: string; //deprecated + /** @deprecated */ + directory?: string; endOffset?: string; includeTrailingDelimiter?: boolean; prefix?: string; @@ -2196,7 +2197,7 @@ class Bucket extends ServiceObject { * truncated after the delimiter, returned in `apiResponse.prefixes`. * Duplicate prefixes are omitted. * @deprecated @property {string} [directory] Filter results based on a directory name, or - * more technically, a "prefix". Deprecated. Use prefix instead. + * 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). @@ -2236,7 +2237,7 @@ class Bucket extends ServiceObject { * truncated after the delimiter, returned in `apiResponse.prefixes`. * Duplicate prefixes are omitted. * @deprecated @param {string} [query.directory] Filter results based on a directory name, or - * more technically, a "prefix". Deprecated. Use query.prefix instead. + * 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).