fix: prevent processing of empty files in PDF service and scanner watcher
Build and Push Multi-Platform Images / build-and-push (push) Successful in 34s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 34s
This commit is contained in:
@@ -40,6 +40,12 @@ export class PdfService {
|
||||
* Verwendet einen einzigen Ghostscript-Aufruf mit %d-Platzhalter für alle Seiten.
|
||||
*/
|
||||
async pdfToImages(pdfPath: string, dpi = 200): Promise<string[]> {
|
||||
const stat = await fs.stat(pdfPath);
|
||||
if (stat.size === 0) {
|
||||
this.logger.warn(`PDF ist leer (0 Bytes), wird übersprungen: ${pdfPath}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pdf-'));
|
||||
|
||||
await execFileAsync('gs', [
|
||||
|
||||
@@ -143,7 +143,7 @@ export class ScannerWatcherService implements OnModuleInit, OnModuleDestroy {
|
||||
private async isStable(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
const stat = await fs.stat(filePath);
|
||||
return Date.now() - stat.mtimeMs >= STABILITY_MS;
|
||||
return stat.size > 0 && Date.now() - stat.mtimeMs >= STABILITY_MS;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
@@ -164,6 +164,17 @@ export class ScannerWatcherService implements OnModuleInit, OnModuleDestroy {
|
||||
const fileName = parts[1];
|
||||
|
||||
if (this.processing.has(filePath)) return;
|
||||
|
||||
try {
|
||||
const stat = await fs.stat(filePath);
|
||||
if (stat.size === 0) {
|
||||
this.logger.debug(`Überspringe leere Datei: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
this.processing.add(filePath);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user