Fixed listFiles() is listing only first 100 files#307
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){ |
packages/lib-js-core/src/hosting.js
Outdated
|
|
||
| return results.concat(nextFetch.objects.slice(0)) | ||
| } | ||
| else { |
There was a problem hiding this comment.
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.
Check this one:
syncano-node/packages/lib-js-core/src/data.js
Line 159 in 3caaaeb
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.
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) { |
packages/lib-js-core/src/hosting.js
Outdated
| } | ||
| return objects | ||
| } catch(err) { | ||
| throw err |
There was a problem hiding this comment.
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.
Same thing as above regarding the error handling.
| next: null | ||
| }) | ||
| return hosting | ||
| .listFiles(hostingId) |
[wip]
Resolves #292
Tested locally but feedback would be much appreciated