From 92c6b59a43cb22986970eceb202e8b625faa79ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 2 Jul 2023 15:32:47 +0100 Subject: [PATCH] fix: error handling when there are no results --- src/util/DatabaseKeyExtractor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/DatabaseKeyExtractor.ts b/src/util/DatabaseKeyExtractor.ts index 5158820..0a4b8e9 100644 --- a/src/util/DatabaseKeyExtractor.ts +++ b/src/util/DatabaseKeyExtractor.ts @@ -32,7 +32,12 @@ export class DatabaseKeyExtractor { return null; } - const keys = db.exec('select file_path, ekey from `audio_file_ekey_table`')[0].values; + const result = db.exec('select file_path, ekey from audio_file_ekey_table'); + if (result.length === 0) { + return []; + } + + const keys = result[0].values; return keys.map(([path, ekey]) => ({ // strip dir name name: getFileName(String(path)),