MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / patch

Method patch

lib/ldp.mjs:685–718  ·  view source on GitHub ↗
(uri, patchObject)

Source from the content-addressed store, hash-verified

683 }
684
685 async patch (uri, patchObject) {
686 if (overQuota(this.quotaFile, this.quota)) {
687 debug.handlers('PATCH -- Over quota')
688 throw error(413, 'Storage quota exceeded')
689 }
690
691 const url = uri
692 let path
693 try {
694 ({ path } = await this.resourceMapper.mapUrlToFile({ url }))
695 } catch (err) {
696 throw error(err.status || 500, err.message)
697 }
698
699 await withLock(path, async () => {
700 let originalData = ''
701
702 try {
703 originalData = await promisify(fs.readFile)(path, { encoding: 'utf8' })
704 } catch (err) {
705 throw error(err, 'Cannot patch a file that does not exist')
706 }
707
708 const contentType = getContentType(path)
709 const patchedData = await this.applyPatch(originalData, patchObject, contentType, uri)
710
711 // Write patched data back to file
712 await promisify(fs.writeFile)(path, patchedData, 'utf8')
713 })
714
715 await clearAclCache()
716
717 debug.handlers('PATCH -- Patched:' + path)
718 }
719
720 async applyPatch (data, patchObject, contentType, uri) {
721 const baseGraph = $rdf.graph()

Callers 6

LdpMiddlewareFunction · 0.80
describePatchFunction · 0.80
acl-tls-test.mjsFile · 0.80
acl-oidc-test.mjsFile · 0.80

Calls 6

applyPatchMethod · 0.95
overQuotaFunction · 0.90
getContentTypeFunction · 0.90
clearAclCacheFunction · 0.90
withLockFunction · 0.85
mapUrlToFileMethod · 0.80

Tested by

no test coverage detected