File tree Expand file tree Collapse file tree
packages/core/src/storages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,8 +147,13 @@ export class DiskStorage extends BaseStorage<DiskFile> {
147147 const lengthChecker = streamLength ( part . contentLength || part . size - part . start ) ;
148148 const checksumChecker = streamChecksum ( part . checksum , part . checksumAlgorithm ) ;
149149 const keepPartial = ! part . checksum ;
150- const failWithCode = ( code ?: ERRORS ) : void => {
150+ const cleanupStreams = ( ) : void => {
151151 dest . close ( ) ;
152+ lengthChecker . destroy ( ) ;
153+ checksumChecker . destroy ( ) ;
154+ } ;
155+ const failWithCode = ( code ?: ERRORS ) : void => {
156+ cleanupStreams ( ) ;
152157 resolve ( [ NaN , code ] ) ;
153158 } ;
154159 lengthChecker . on ( 'error' , ( ) => failWithCode ( ERRORS . FILE_CONFLICT ) ) ;
@@ -158,7 +163,10 @@ export class DiskStorage extends BaseStorage<DiskFile> {
158163 . pipe ( lengthChecker )
159164 . pipe ( checksumChecker )
160165 . pipe ( dest )
161- . on ( 'error' , reject )
166+ . on ( 'error' , ( err ?: unknown ) : void => {
167+ cleanupStreams ( ) ;
168+ reject ( err ) ;
169+ } )
162170 . on ( 'finish' , ( ) => {
163171 return resolve ( [ part . start + dest . bytesWritten ] ) ;
164172 } ) ;
You can’t perform that action at this time.
0 commit comments