Move repository content images to S3-backed media references

This commit is contained in:
2026-10-29 23:03:11 +08:00
parent 906c6985cb
commit 19bba57561
630 changed files with 5666 additions and 391 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
import {readRepositoryMedia} from './managed-media.mjs';
/** Local authoring client. Publishes text/images exclusively through existing generic Wiki APIs. */
import {readFile,writeFile,mkdir} from 'node:fs/promises';
import {createHash} from 'node:crypto';
@@ -21,7 +22,7 @@ const assetNames=new Set(['router-cover.png','source.png','numbered-source.png']
for(const l of raw){for(const field of ['reference','annotated','background'])assetNames.add(l[field].slice('asset:'.length));for(const kind of ['text','image','decoration'])assetNames.add(`${l.id}/${kind}-map.png`);for(const e of l.elements)for(const field of ['asset','mask','underlay'])if(e[field])assetNames.add(e[field].slice('asset:'.length))}
const byFile={},pending=[];
for(const name of [...assetNames].sort()){
const bytes=await readFile(path.join(dataRoot,'assets',name)),hash=createHash('sha256').update(bytes).digest('hex');byFile[name]={bytes,hash};
const bytes=await readRepositoryMedia('content/layout-reference/assets/'+name),hash=createHash('sha256').update(bytes).digest('hex');byFile[name]={bytes,hash};
if(!state.assets[hash]&&!pending.some(a=>a.hash===hash))pending.push({name,bytes,hash});
}
if(!dryRun){