Skip to content

[BUG] Sync list does not work #308

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

Closed
movitto opened this issue Jan 13, 2022 · 1 comment · Fixed by #309
Closed

[BUG] Sync list does not work #308

movitto opened this issue Jan 13, 2022 · 1 comment · Fixed by #309

Comments

@movitto
Copy link

movitto commented Jan 13, 2022

Listing of a tarball contents works in asynchronous mode, but when 'sync' is passed to tar.t, undefined is returned.

Fedora 33. nodejs v14.18.1. tar v1.32

The following works:

var entries = [];
await tar.t({
  file : 'mytarball.tgz',
  onentry : e => entries.push(e.header.path)
})
console.log(entries) # ['file1', 'file2', etc]

But the following does not work:

var entries = tar.t({
  file : 'mytarball.tgz',
  sync : true
})
console.log(entries) # undefined

Any insight as to why this is would be highly appreciated.

@isaacs
Copy link
Owner

isaacs commented Feb 27, 2022

It doesn't return a list of entries. You still have to give it an onentry method. It'll just call that method synchronously, rather than calling it at some point in the future.

var entries = [];
tar.t({
  file : 'mytarball.tgz',
  onentry : e => entries.push(e.header.path),
  sync: true,
})
console.log(entries) # ['file1', 'file2', etc]

Otherwise, it would potentially be storing a huge amount of data in memory. All the sync functions work exactly the same as the async ones, just sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants