-
Notifications
You must be signed in to change notification settings - Fork 9
Fixed listFiles() is listing only first 100 files #307
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #307 +/- ##
========================================
- Coverage 39.42% 32% -7.42%
========================================
Files 87 84 -3
Lines 2765 2431 -334
Branches 10 6 -4
========================================
- Hits 1090 778 -312
+ Misses 1674 1653 -21
+ Partials 1 0 -1 |
|
Please add unit test for this case. |
packages/lib-js-core/src/hosting.js
Outdated
| }) | ||
| } | ||
|
|
||
| async fetchNextListFiles(hasNext, results){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before {.
packages/lib-js-core/src/hosting.js
Outdated
|
|
||
| return results.concat(nextFetch.objects.slice(0)) | ||
| } | ||
| else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this else here because you have return above.
packages/lib-js-core/src/hosting.js
Outdated
| } | ||
| let results = [] | ||
| const initialFetch = await this.fetch(this.urlFiles(hostingId), {}, headers) | ||
| const hasNext = initialFetch.next; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this one:
syncano-node/packages/lib-js-core/src/data.js
Line 159 in 3caaaeb
| async loadNextPage (response, objects) { |
It is very similar, try to use same variable names and constructions.
packages/lib-js-core/src/hosting.js
Outdated
| debug('listFiles') | ||
| const headers = { | ||
| 'X-API-KEY': this.instance.accountKey | ||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it is obsolete. You are catching err to throw err. This is async operation just return this.request you don't even need await here.
packages/lib-js-core/src/hosting.js
Outdated
| return objects.concat(nextObjects) | ||
| } | ||
| return objects | ||
| } catch(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style.
packages/lib-js-core/src/hosting.js
Outdated
| } | ||
| return objects | ||
| } catch(err) { | ||
| throw err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as above regarding the error handling.
packages/lib-js-core/src/hosting.js
Outdated
| let objects = result.objects | ||
| objects = await this.loadNextPage(result, objects) | ||
| return objects | ||
| } catch (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as above regarding the error handling.
| next: null | ||
| }) | ||
| return hosting | ||
| .listFiles(hostingId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indent.
mkucharz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[wip]
Resolves #292
Tested locally but feedback would be much appreciated