(ldp, resourceGraph, containerUri, reqUri, container, file)
| 31 | } |
| 32 | |
| 33 | async function addFile (ldp, resourceGraph, containerUri, reqUri, container, file) { |
| 34 | // Skip .meta and .acl |
| 35 | if (file.endsWith(ldp.suffixMeta) || file.endsWith(ldp.suffixAcl)) { |
| 36 | return null |
| 37 | } |
| 38 | |
| 39 | const filePath = path.join(container, file) |
| 40 | |
| 41 | // Get file stats |
| 42 | let stats |
| 43 | try { |
| 44 | stats = await ldp.stat(filePath) |
| 45 | } catch (e) { |
| 46 | return null |
| 47 | } |
| 48 | const memberUri = reqUri + (stats.isDirectory() ? '/' : '') |
| 49 | |
| 50 | // Add fileStats to resource Graph |
| 51 | addStats(resourceGraph, memberUri, stats, file) |
| 52 | |
| 53 | // Add to `contains` list |
| 54 | resourceGraph.add( |
| 55 | resourceGraph.sym(containerUri), |
| 56 | ns.ldp('contains'), |
| 57 | resourceGraph.sym(memberUri)) |
| 58 | |
| 59 | // Set up a metaFile path |
| 60 | // Earlier code used a .ttl file as its own meta file, which |
| 61 | // caused massive data files to parsed as part of deirectory listings just looking for type triples |
| 62 | const metaFile = containerUri + file + ldp.suffixMeta |
| 63 | |
| 64 | let metadataGraph |
| 65 | try { |
| 66 | metadataGraph = await getMetadataGraph(ldp, metaFile, memberUri) |
| 67 | } catch (err) { |
| 68 | metadataGraph = $rdf.graph() |
| 69 | } |
| 70 | |
| 71 | // Add Container or BasicContainer types |
| 72 | if (stats.isDirectory()) { |
| 73 | resourceGraph.add( |
| 74 | metadataGraph.sym(memberUri), |
| 75 | ns.rdf('type'), |
| 76 | ns.ldp('BasicContainer')) |
| 77 | |
| 78 | resourceGraph.add( |
| 79 | metadataGraph.sym(memberUri), |
| 80 | ns.rdf('type'), |
| 81 | ns.ldp('Container')) |
| 82 | } |
| 83 | // Add generic LDP type |
| 84 | resourceGraph.add( |
| 85 | metadataGraph.sym(memberUri), |
| 86 | ns.rdf('type'), |
| 87 | ns.ldp('Resource')) |
| 88 | |
| 89 | // Add type from metadataGraph |
| 90 | metadataGraph |
nothing calls this directly
no test coverage detected