From c1476a3337e10f0fbced7e6435a6636fe6d38230 Mon Sep 17 00:00:00 2001 From: go0p Date: Tue, 18 Aug 2026 14:49:44 +0800 Subject: [PATCH] fix(ci): read ali-oss head() result through res.headers/meta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit head() resolves to { meta, res, status } — raw headers live at res.headers and x-oss-meta-* values are pre-parsed into meta. The previous direct res.headers access crashed the post-upload verification after the first successful put. --- scripts/publish-oss.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/publish-oss.mjs b/scripts/publish-oss.mjs index 6330139..7e64d2b 100644 --- a/scripts/publish-oss.mjs +++ b/scripts/publish-oss.mjs @@ -60,12 +60,14 @@ const client = new OSS({ accessKeyId, accessKeySecret, bucket, endpoint, secure: const sha256 = (buffer) => createHash('sha256').update(buffer).digest('hex'); +// head() resolves to { meta, res, status }: raw headers live at res.headers +// and x-oss-meta-* values are pre-parsed into meta. async function headObject(key) { try { - const res = await client.head(key); + const result = await client.head(key); return { - size: Number(res.headers['content-length']), - sha256: res.headers['x-oss-meta-sha256'] ?? null, + size: Number(result.res.headers['content-length']), + sha256: result.meta?.sha256 ?? null, }; } catch (err) { if (err && (err.status === 404 || err.code === 'NoSuchKey')) return null;