fix(config): migrate project config and harden SmartFile and StreamFile defaults for updated toolchain compatibility

This commit is contained in:
2026-04-30 07:29:24 +00:00
parent 66c8de91ee
commit 8a9c4175dc
8 changed files with 2697 additions and 3938 deletions
+12 -4
View File
@@ -33,7 +33,11 @@ export class StreamFile {
const response = await plugins.smartrequest.SmartRequest.create()
.url(url)
.get();
return response.stream();
const responseStream = response.stream();
if (!responseStream) {
throw new Error(`No response stream available for ${url}`);
}
return responseStream;
};
const streamFile = new StreamFile(streamSource, undefined, smartFs);
streamFile.multiUse = true;
@@ -117,9 +121,9 @@ export class StreamFile {
// enable stream based multi use
private cachedStreamBuffer?: Buffer;
public multiUse: boolean;
public multiUse: boolean = false;
public used: boolean = false;
public byteLengthComputeFunction: () => Promise<number>;
public byteLengthComputeFunction?: () => Promise<number>;
private constructor(streamSource: TStreamSource, relativeFilePath?: string, smartFs?: any) {
this.streamSource = streamSource;
@@ -185,6 +189,10 @@ export class StreamFile {
}
this.checkMultiUse();
if (!this.relativeFilePath) {
throw new Error('Cannot write stream to directory without a relative file path.');
}
const filePath = plugins.path.join(dirPathArg, this.relativeFilePath);
const dirPath = plugins.path.parse(filePath).dir;
await this.smartFs.directory(dirPath).recursive().create();
@@ -213,7 +221,7 @@ export class StreamFile {
/**
* Returns the size of the file content in bytes.
*/
public async getSize(): Promise<number> {
public async getSize(): Promise<number | null> {
if (this.byteLengthComputeFunction) {
return this.byteLengthComputeFunction();
} else {