feat(images): improve image operations UI and record archive metadata
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user