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

Method listContainer

lib/ldp.mjs:96–128  ·  view source on GitHub ↗
(container, reqUri, containerData, hostname)

Source from the content-addressed store, hash-verified

94 }
95
96 async listContainer (container, reqUri, containerData, hostname) {
97 const resourceGraph = $rdf.graph()
98 try {
99 $rdf.parse(containerData, resourceGraph, reqUri, 'text/turtle')
100 } catch (err) {
101 debug.handlers('GET -- Error parsing data: ' + err)
102 throw error(500, "Can't parse container .meta")
103 }
104
105 try {
106 // add container stats
107 await ldpContainer.addContainerStats(this, reqUri, container, resourceGraph)
108 // read directory
109 const files = await ldpContainer.readdir(container)
110 // iterate through all the files
111 await Promise.all(files.map(async file => {
112 const { url: fileUri } = await this.resourceMapper.mapFileToUrl(
113 { path: join(container, file), hostname })
114 return await ldpContainer.addFile(this, resourceGraph, reqUri, fileUri, container, file)
115 }))
116 } catch (err) {
117 throw error(500, "Can't list container")
118 }
119
120 // TODO 'text/turtle' is fixed, should be contentType instead
121 // This forces one more translation turtle -> desired
122 try {
123 return await serialize(resourceGraph, reqUri, 'text/turtle')
124 } catch (err) {
125 debug.handlers('GET -- Error serializing container: ' + err)
126 throw error(500, "Can't serialize container")
127 }
128 }
129
130 async post (hostname, containerPath, stream, { container, slug, extension, contentType }) {
131 // POST without content type is forbidden

Callers 2

getMethod · 0.95
ldp-test.mjsFile · 0.80

Calls 3

serializeFunction · 0.90
graphMethod · 0.80
mapFileToUrlMethod · 0.80

Tested by

no test coverage detected