From cc14e787bc04bb3b4b54a919bc0eae5431014869 Mon Sep 17 00:00:00 2001 From: Chris Millar Date: Mon, 30 Jun 2025 10:23:54 -0600 Subject: [PATCH] Revert "fix: last modified header for source (#145)" This reverts commit edf1de1344ab61b052cf40c41254b20428394e94. --- src/storage/object/get.js | 10 ++-------- src/utils/daResp.js | 4 ++-- test/utils/daResp.test.js | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/storage/object/get.js b/src/storage/object/get.js index 4b4fbf13..efb21604 100644 --- a/src/storage/object/get.js +++ b/src/storage/object/get.js @@ -36,10 +36,7 @@ export default async function getObject(env, { org, key }, head = false) { status: resp.$metadata.httpStatusCode, contentType: resp.ContentType, contentLength: resp.ContentLength, - metadata: { - ...resp.Metadata, - LastModified: resp.LastModified, - }, + metadata: resp.Metadata, etag: resp.ETag, }; } catch (e) { @@ -59,10 +56,7 @@ export default async function getObject(env, { org, key }, head = false) { status: resp.status, contentType: resp.headers.get('content-type'), contentLength: resp.headers.get('content-length'), - metadata: { - ...resp.Metadata, - LastModified: resp.headers.get('last-modified'), - }, + metadata: Metadata, etag: resp.headers.get('etag'), }; } diff --git a/src/utils/daResp.js b/src/utils/daResp.js index 04f75b06..c52ac4fb 100644 --- a/src/utils/daResp.js +++ b/src/utils/daResp.js @@ -29,8 +29,8 @@ export default function daResp({ headers.append('X-da-id', metadata.id); } - if (metadata?.LastModified) { - headers.append('Last-Modified', new Date(metadata.LastModified).toUTCString()); + if (metadata?.timestamp) { + headers.append('Last-Modified', new Date(parseInt(metadata.timestamp, 10)).toUTCString()); } if (ctx?.aclCtx && status < 500) { diff --git a/test/utils/daResp.test.js b/test/utils/daResp.test.js index 16e2a083..dde77221 100644 --- a/test/utils/daResp.test.js +++ b/test/utils/daResp.test.js @@ -19,7 +19,7 @@ describe('DA Resp', () => { const aclCtx = { actionSet: ['read', 'write'], pathLookup: new Map() }; const ctx = { key: 'foo/bar.html', aclCtx }; const body = 'foobar'; - const metadata = { id: '1234', LastModified: '2024-06-24T13:20:00.000Z' }; + const metadata = { id: '1234', timestamp: '1719235200000' }; const resp = daResp({status: 200, body, contentType: 'text/plain', contentLength: 777, metadata}, ctx); assert.strictEqual(body, await resp.text());