1
0
Fork 0

Update getArchiveType method

pull/1552/head
Nikolai Laevskii 2023-10-09 06:57:28 +02:00
parent 5c16ddf520
commit 508df3dce8
1 changed files with 4 additions and 10 deletions

View File

@ -70,20 +70,14 @@ export const getArchiveType = async (filePath: string): Promise<ArchiveType> =>
const readStream = readStreamFromDescriptor(fd)
const closeEverythingAndResolve = (result: ArchiveType): void => {
readStream.close(() => {
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
})
readStream.close()
fs.close(fd, () => resolve(result as '7z' | 'zip' | 'xar' | 'tar'))
readStream.push(null)
}
const closeEverythingAndReject = (error?: Error): void => {
readStream.close(() => {
fs.close(fd, () =>
reject(
error ?? Error(`Unable to determine archive type of ${filePath}`)
)
)
})
readStream.close()
fs.close(fd, () => reject(error ?? Error('Unable to read file')))
readStream.push(null)
}