fix(core): update

This commit is contained in:
2024-06-06 00:32:50 +02:00
parent eaaf313442
commit e48023d490
5 changed files with 220 additions and 4 deletions

View File

@@ -3,7 +3,14 @@ import * as paths from './paths.js';
import type { DockerHost } from './classes.host.js';
export interface IDockerImageStoreConstructorOptions {
dirPath: string;
/**
* used for preparing images for longer term storage
*/
localDirPath: string;
/**
* a smartbucket dir for longer term storage.
*/
bucketDir: plugins.smartbucket.Directory;
}
export class DockerImageStore {
@@ -15,7 +22,7 @@ export class DockerImageStore {
// Method to store tar stream
public async storeImage(imageName: string, tarStream: plugins.smartstream.stream.Readable): Promise<void> {
const imagePath = plugins.path.join(this.options.dirPath, `${imageName}.tar`);
const imagePath = plugins.path.join(this.options.localDirPath, `${imageName}.tar`);
// Create a write stream to store the tar file
const writeStream = plugins.smartfile.fsStream.createWriteStream(imagePath);
@@ -30,7 +37,7 @@ export class DockerImageStore {
// Method to retrieve tar stream
public async getImage(imageName: string): Promise<plugins.smartstream.stream.Readable> {
const imagePath = plugins.path.join(this.options.dirPath, `${imageName}.tar`);
const imagePath = plugins.path.join(this.options.localDirPath, `${imageName}.tar`);
if (!(await plugins.smartfile.fs.fileExists(imagePath))) {
throw new Error(`Image ${imageName} does not exist.`);