From 043eee445d022e47e3f06d4770797034ff580a3a Mon Sep 17 00:00:00 2001 From: Enis Date: Sun, 27 Aug 2023 20:12:19 +0200 Subject: [PATCH] fixed serial printer file not found bug --- src/lib/server/fileUtil.ts | 4 ++-- src/lib/server/print/printers/serialPrinter.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/server/fileUtil.ts b/src/lib/server/fileUtil.ts index b8c980f..f4ee4cc 100644 --- a/src/lib/server/fileUtil.ts +++ b/src/lib/server/fileUtil.ts @@ -30,9 +30,9 @@ async function createEmptyJsonFile(path: string) { await storeObject({}, path); } -export async function fileExists(path: string) { +export async function fileExists(path: string, inDataPath = true) { try { - await fs.access(getDataFilePathFor(path)); + await fs.access(inDataPath ? getDataFilePathFor(path) : path); return true; } catch { return false; diff --git a/src/lib/server/print/printers/serialPrinter.ts b/src/lib/server/print/printers/serialPrinter.ts index dbe5744..9573334 100644 --- a/src/lib/server/print/printers/serialPrinter.ts +++ b/src/lib/server/print/printers/serialPrinter.ts @@ -13,7 +13,7 @@ export class SerialPrinter extends Printer { */ public async print(zpl: string): Promise { const path = this.options.path; - if (!path || !(await fileExists(path))) { + if (!path || !(await fileExists(path, false))) { throw new Error(`${path} not found`); }