FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: include stat metadata in container listings by melvincarvalho · Pull Request #225 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub

Repository navigation

feat: include stat metadata in container listings - #225

Merged
melvincarvalho merged 2 commits into
gh-pagesfrom
issue-224-container-stat-metadata
Mar 22, 2026
Merged

melvincarvalho merged 2 commits into
gh-pagesfrom
issue-224-container-stat-metadata

Conversation

Copy link
Copy Markdown
Contributor

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

Add stat:size and dcterms:modified to container listing entries.
Data comes from fs.stat() run in parallel via Promise.all.

Fixes #224

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Adds filesystem-derived metadata to LDP container listings so clients can render richer folder views without issuing per-item HEAD requests.

Changes:

  • Extend filesystem container listings to include per-entry size and modified (mtime) via parallel fs.stat() calls.
  • Emit stat:size and dcterms:modified fields in generated container JSON-LD and add stat/dcterms prefixes to the JSON-LD context.

Reviewed 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.

Comment thread src/storage/filesystem.js Outdated
* 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>}

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Suggested change
* @returns {Promise<Array<{name: string, isDirectory: boolean, size: number, modified: string}> | null>}
* @returns {Promise<Array<{name: string, isDirectory: boolean, size?: number, modified?: string}> | null>}

Copilot uses AI. Check for mistakes.
Comment thread src/ldp/container.js
Comment on lines 21 to +25
'@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;

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copilot uses AI. Check for mistakes.
melvincarvalho merged commit e3f2aeb into gh-pages Mar 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include stat metadata (size, modified) in container listings

2 participants


Back | FazBrowse Home | New Git URL