File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const parse = require('./utils').parse
1717const fetch = require ( 'node-fetch' )
1818const { promisify } = require ( 'util' )
1919const URI = require ( 'urijs' )
20+ const { lock } = require ( 'proper-lockfile' )
2021
2122const RDF_MIME_TYPES = new Set ( [
2223 'text/turtle' , // .ttl
@@ -95,11 +96,17 @@ class LDP {
9596 }
9697
9798 async readResource ( url ) {
99+ let releaseLock
98100 try {
99101 const { path } = await this . resourceMapper . mapUrlToFile ( { url } )
102+ releaseLock = await lock ( path , { retries : 10 } )
100103 return await promisify ( fs . readFile ) ( path , { encoding : 'utf8' } )
101104 } catch ( err ) {
102105 throw error ( err . status , err . message )
106+ } finally {
107+ if ( releaseLock ) {
108+ await releaseLock ( )
109+ }
103110 }
104111 }
105112
You can’t perform that action at this time.
0 commit comments