Skip to content

Commit

Permalink
list: close file even if no error thrown
Browse files Browse the repository at this point in the history
Fix: #404
  • Loading branch information
isaacs committed Apr 10, 2024
1 parent b3afdbb commit 314ec7e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const filesFilter = (opt: TarOptions, files: string[]) => {
const listFileSync = (opt: TarOptionsSyncFile) => {
const p = list_(opt)
const file = opt.file
let threw = true
let fd
try {
const stat = fs.statSync(file)
Expand All @@ -148,9 +147,8 @@ const listFileSync = (opt: TarOptionsSyncFile) => {
}
p.end()
}
threw = false
} finally {
if (threw && fd) {
if (typeof fd === 'number') {
try {
fs.closeSync(fd)
/* c8 ignore next */
Expand Down

0 comments on commit 314ec7e

Please sign in to comment.