feat(images): improve image operations UI and record archive metadata

This commit is contained in:
2026-05-26 09:54:26 +00:00
parent 05560c9db9
commit 56a62e7008
9 changed files with 398 additions and 548 deletions
+15 -1
View File
@@ -116,12 +116,15 @@ export class ImageManager {
await refImage.save();
const imagePushStream = reqArg.imageStream;
(async () => {
const archiveHash = plugins.crypto.createHash('sha256');
let archiveSize = 0;
const smartWebDuplex = new plugins.smartstream.webstream.WebDuplexStream<
Uint8Array,
Uint8Array
>({
writeFunction: async (chunkArg, toolsArg) => {
console.log(chunkArg);
archiveSize += chunkArg.byteLength;
archiveHash.update(chunkArg);
return chunkArg;
},
});
@@ -130,6 +133,17 @@ export class ImageManager {
storagePath,
plugins.smartstream.SmartDuplex.fromWebReadableStream(smartWebDuplex.readable),
);
refImage.data.versions = refImage.data.versions.map((versionArg) => {
if (versionArg.versionString !== imageVersion) {
return versionArg;
}
return {
...versionArg,
size: archiveSize,
digest: `sha256:${archiveHash.digest('hex')}`,
};
});
await refImage.save();
})().catch((error) => {
console.error(`failed to store image ${refImage.id}:${imageVersion}`, error);
});