| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add stat:size and dcterms:modified to container listing entries. Data comes from fs.stat() run in parallel via Promise.all. Fixes #224
There was a problem hiding this comment.
Adds filesystem-derived metadata to LDP container listings so clients can render richer folder views without issuing per-item HEAD requests.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/storage/filesystem.js | Augments listContainer() results with fs.stat() metadata per entry. |
| src/ldp/container.js | Serializes new metadata fields into container contains entries and updates JSON-LD context prefixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| * List container contents with stat metadata | ||
| * @param {string} urlPath | ||
| * @returns {Promise<Array<{name: string, isDirectory: boolean}> | null>} | ||
| * @returns {Promise<Array<{name: string, isDirectory: boolean, size: number, modified: string}> | null>} |
There was a problem hiding this comment.
The JSDoc return type marks size and modified as always present, but the implementation intentionally omits them when fs.stat() fails (and they can also be omitted if you keep the catch). Update the type to make these fields optional (or explicitly return null for them) so callers and tooling don’t assume they’re guaranteed.
| * @returns {Promise<Array<{name: string, isDirectory: boolean, size: number, modified: string}> | null>} | |
| * @returns {Promise<Array<{name: string, isDirectory: boolean, size?: number, modified?: string}> | null>} |
Sorry, something went wrong.
| '@type': entry.isDirectory ? [`${LDP}Container`, `${LDP}BasicContainer`, `${LDP}Resource`] : [`${LDP}Resource`] | ||
| }; | ||
| if (entry.size != null) item['stat:size'] = entry.size; | ||
| if (entry.modified) item['dcterms:modified'] = entry.modified; | ||
| return item; |
There was a problem hiding this comment.
Including per-entry stat:size / dcterms:modified changes the container listing body when a child file changes, but the GET handler’s conditional responses use an ETag derived from the directory’s stat (mtime/size). On many filesystems the directory mtime does not change when a contained file is modified, so clients can incorrectly receive 304 Not Modified for a changed listing. Consider computing the container listing ETag from the listing content (e.g., hash of sorted {name,isDirectory,size,modified}) instead of the directory stat.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Add stat:size (bytes) and dcterms:modified (ISO timestamp) to container listing entries. Enables richer folder views without per-item HEAD requests.
Before:
{ "@id": "/public/data.json", "@type": ["ldp:Resource"] }After:
{ "@id": "/public/data.json", "@type": ["ldp:Resource"], "stat:size": 1234, "dcterms:modified": "2026-03-22T07:00:00Z" }~10 lines changed. fs.stat() calls run in parallel via Promise.all. 347 tests pass.
Fixes #224