fix(sql-library): decode imported SQL files

This commit is contained in:
zipg
2026-07-22 13:27:26 +08:00
committed by GitHub
parent a94a6e3f84
commit 5528f4e223
2 changed files with 15 additions and 2 deletions
@@ -235,7 +235,6 @@ async function importDirectoryIntoLibrary(targetFolder?: SavedSqlFolder) {
try {
const { open } = await import("@tauri-apps/plugin-dialog");
const { readTextFile } = await import("@tauri-apps/plugin-fs");
const selected = await open({
directory: true,
multiple: false,
@@ -253,7 +252,7 @@ async function importDirectoryIntoLibrary(targetFolder?: SavedSqlFolder) {
const takenNames = new Set((targetFolder ? savedSqlStore.filesInFolder(targetFolder.id) : savedSqlStore.filesWithoutFolder()).filter((file) => !orphanedIds.value.has(file.id)).map((file) => file.name));
for (const path of sqlPaths) {
const content = await readTextFile(path);
const content = await api.readExternalSqlFile(path);
const displayName = uniqueImportedName(relativeImportName(selected, path), takenNames);
await savedSqlStore.saveFile({
connectionId,
+14
View File
@@ -0,0 +1,14 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "vitest";
const source = readFileSync("apps/desktop/src/components/layout/SqlLibraryPanel.vue", "utf8");
test("SQL library imports use the charset-aware external SQL reader", () => {
const start = source.indexOf("async function importDirectoryIntoLibrary");
const end = source.indexOf("async function chooseSyncDirectory", start);
const handler = start >= 0 && end > start ? source.slice(start, end) : "";
assert.match(handler, /await api\.readExternalSqlFile\(path\)/);
assert.doesNotMatch(handler, /readTextFile/);
});