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

Function doWrite

lib/handlers/patch.mjs:205–221  ·  view source on GitHub ↗
(serialized)

Source from the content-addressed store, hash-verified

203 const resourceSym = graph.sym(resource.url)
204
205 function doWrite (serialized) {
206 // First check if we are above quota
207 overQuota(root, serverUri).then((isOverQuota) => {
208 if (isOverQuota) {
209 return reject(error(413,
210 'User has exceeded their storage quota'))
211 }
212
213 fs.writeFile(resource.path, serialized, { encoding: 'utf8' }, function (err) {
214 if (err) {
215 return reject(error(500, `Failed to write file after patch: ${err}`))
216 }
217 debug('PATCH -- applied successfully')
218 resolve('Patch applied successfully.\n')
219 })
220 }).catch(() => reject(error(500, 'Error finding user quota')))
221 }
222
223 if (resource.contentType === 'application/ld+json') {
224 $rdf.serialize(resourceSym, graph, resource.url, resource.contentType, function (err, result) {

Callers 1

writeGraphFunction · 0.85

Calls 1

overQuotaFunction · 0.90

Tested by

no test coverage detected