File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -255,16 +255,24 @@ class LDP {
255255 }
256256
257257 // Directory created, now write the file
258- return await new Promise ( ( resolve , reject ) => {
259- const file = stream . pipe ( fs . createWriteStream ( path ) )
260- file . on ( 'error' , function ( ) {
261- reject ( error ( 500 , 'Error writing data' ) )
262- } )
263- file . on ( 'finish' , function ( ) {
264- debug . handlers ( 'PUT -- Wrote data to: ' + path )
265- resolve ( )
258+ let releaseLock
259+ try {
260+ releaseLock = await lock ( path , { retries : 10 , realpath : false } )
261+ return await new Promise ( ( resolve , reject ) => {
262+ const file = stream . pipe ( fs . createWriteStream ( path ) )
263+ file . on ( 'error' , function ( ) {
264+ reject ( error ( 500 , 'Error writing data' ) )
265+ } )
266+ file . on ( 'finish' , function ( ) {
267+ debug . handlers ( 'PUT -- Wrote data to: ' + path )
268+ resolve ( )
269+ } )
266270 } )
267- } )
271+ } finally {
272+ if ( releaseLock ) {
273+ await releaseLock ( )
274+ }
275+ }
268276 }
269277
270278 async exists ( hostname , path , searchIndex = true ) {
You can’t perform that action at this time.
0 commit comments