From 1d7dc04f54d95be21f3257dbe403fe14c2be470a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 13 Nov 2023 10:32:40 +0100 Subject: [PATCH] Fixes #563 --- common/spaces/disk_space_primitives.ts | 12 ++++++------ plugos/syscalls/fs.deno.ts | 12 ++++++------ plugs/template/api.ts | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/common/spaces/disk_space_primitives.ts b/common/spaces/disk_space_primitives.ts index 8f1094a..9e16ca9 100644 --- a/common/spaces/disk_space_primitives.ts +++ b/common/spaces/disk_space_primitives.ts @@ -54,8 +54,8 @@ export class DiskSpacePrimitives implements SpacePrimitives { data, meta: { name: name, - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, perm: "rw", size: s.size, contentType: contentType, @@ -109,8 +109,8 @@ export class DiskSpacePrimitives implements SpacePrimitives { name: name, size: s.size, contentType: lookupContentType(name), - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, perm: "rw", }; } catch { @@ -147,8 +147,8 @@ export class DiskSpacePrimitives implements SpacePrimitives { } allFiles.push({ name: normalizeForwardSlashPath(name), - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, contentType: mime.getType(fullPath) || "application/octet-stream", size: s.size, perm: "rw", diff --git a/plugos/syscalls/fs.deno.ts b/plugos/syscalls/fs.deno.ts index 8f29ee5..5c419e0 100644 --- a/plugos/syscalls/fs.deno.ts +++ b/plugos/syscalls/fs.deno.ts @@ -34,8 +34,8 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping { const s = await Deno.stat(p); return { name: filePath, - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, contentType: mime.getType(filePath) || "application/octet-stream", size: s.size, perm: "rw", @@ -57,8 +57,8 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping { const s = await Deno.stat(p); return { name: filePath, - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, contentType: mime.getType(filePath) || "application/octet-stream", size: s.size, perm: "rw", @@ -86,8 +86,8 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping { const s = await Deno.stat(fullPath); allFiles.push({ name: fullPath.substring(dirPath.length + 1), - created: s.birthtime!.getTime(), - lastModified: s.mtime!.getTime(), + created: s.birthtime?.getTime() || s.mtime?.getTime() || 0, + lastModified: s.mtime?.getTime() || 0, contentType: mime.getType(fullPath) || "application/octet-stream", size: s.size, perm: "rw", diff --git a/plugs/template/api.ts b/plugs/template/api.ts index 9443419..5300087 100644 --- a/plugs/template/api.ts +++ b/plugs/template/api.ts @@ -23,7 +23,6 @@ export async function renderTemplate( removeTags: ["template"], }); templateText = renderToText(tree).trimStart(); - // console.log(`Trimmed template: |${templateText}|`); // If a 'frontmatter' key was specified in the frontmatter, use that as the frontmatter if (frontmatter.frontmatter) { if (typeof frontmatter.frontmatter === "string") {