diff --git a/src/services/ImportService/ExpoReadStream.ts b/src/services/ImportService/ExpoReadStream.ts index 722d57e..db592b5 100644 --- a/src/services/ImportService/ExpoReadStream.ts +++ b/src/services/ImportService/ExpoReadStream.ts @@ -23,7 +23,7 @@ export class ExpoReadStream extends Readable { this.chunkSize = options.length ?? 1024 * 1024 * 5; } - public async init() { + public async init(): Promise { try { const fileInfo = await fs.getInfoAsync(this.fileUri, { size: true }); if (fileInfo.exists) { @@ -34,8 +34,10 @@ export class ExpoReadStream extends Readable { if (this.fileSize === 0) { console.warn(`File size is 0, Exist: ${String(fileInfo.exists)}, path: ${this.fileUri}`); } + return this.fileSize; } catch (error) { this.emit('error', error); + return this.fileSize; } } diff --git a/src/services/ImportService/index.ts b/src/services/ImportService/index.ts index 381a765..4377f48 100644 --- a/src/services/ImportService/index.ts +++ b/src/services/ImportService/index.ts @@ -256,7 +256,12 @@ export class ImportService { readStream.on('progress', (progress: number) => { setProgress.setReadListProgress(progress); }); - await readStream.init(); + const fileSize = await readStream.init(); + if (fileSize <= 2) { + // 2 means `[]`, empty array + console.log('loadBinaryTiddlersAsFilesFromServer: No binary tiddlers to load.'); + return; + } const countBinaryTiddlerFieldsStream = chain([ readStream, StreamArray.withParser(),