feat(images): improve image operations UI and record archive metadata
This commit is contained in:
@@ -12,15 +12,18 @@ export class Image extends plugins.smartdata.SmartDataDbDoc<
|
||||
) {
|
||||
const image = new Image();
|
||||
image.id = await this.getNewId();
|
||||
console.log(imageDataArg);
|
||||
Object.assign(image, {
|
||||
data: {
|
||||
name: imageDataArg.name,
|
||||
description: imageDataArg.description,
|
||||
location: imageDataArg.location || {
|
||||
internal: true,
|
||||
externalRegistryId: '',
|
||||
externalImageTag: '',
|
||||
},
|
||||
versions: [],
|
||||
},
|
||||
});
|
||||
console.log((Image as any).saveableProperties);
|
||||
await image.save();
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -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