@samitouri / QOSami-HFS / commits / dcbb5b30

fix: zipping an inaccessible file (EACCES) would hang the download

Massimo Melina committed Dec 30, 2023 at 23:34 UTC dcbb5b30aad63dfd2b7f6d892684b6f3609b5468
1 file changed +8 -2
src/QuickZipStream.ts
+8 -2
@@ -159,13 +159,19 @@ export class QuickZipStream extends Readable {
159 return
160 }
161 const data = getData()
162 - data.on('error', (err) => console.error(err))
163 - data.on('end', ()=>{
162 + data.on('error', (err) => {
163 + if ((err as any)?.code !== 'EACCES')
164 + console.error('zipping:', String(err))
165 + data.destroy(err)
166 this.workingFile = undefined
167 + this.push('') // continue piping
168 + })
169 + data.on('end', ()=>{
170 entry.crc = crc
171 if (sourcePath)
172 crcCache[sourcePath] = { ts, crc }
173 this.entries.push(entry)
174 + this.workingFile = undefined
175 this.push('') // continue piping
176 })
177 this.workingFile = data