File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
plugins/local-storage/src Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ class LocalFS implements ILocalPackageManager {
179179
180180 const temporalName = path . join ( this . path , `${ name } .tmp-${ String ( Math . random ( ) ) . replace ( / ^ 0 \. / , '' ) } ` ) ;
181181 const file = fs . createWriteStream ( temporalName ) ;
182+ const removeTempFile = ( ) => fs . unlink ( temporalName , function ( ) { } ) ;
182183 let opened = false ;
183184 uploadStream . pipe ( file ) ;
184185
@@ -201,15 +202,20 @@ class LocalFS implements ILocalPackageManager {
201202 uploadStream . on ( 'end' , onend ) ;
202203 }
203204 } ;
205+
204206 uploadStream . abort = function ( ) {
205207 if ( opened ) {
206208 opened = false ;
207209 file . on ( 'close' , function ( ) {
208- fs . unlink ( temporalName , function ( ) { } ) ;
210+ removeTempFile ( ) ;
209211 } ) ;
212+ } else {
213+ // if the file does not recieve any byte never is opened and has to be removed anyway.
214+ removeTempFile ( ) ;
210215 }
211216 file . end ( ) ;
212217 } ;
218+
213219 file . on ( 'open' , function ( ) {
214220 opened = true ;
215221 // re-emitting open because it's handled in storage.js
You can’t perform that action at this time.
0 commit comments