fix(editor): protect external SQL files from conflicting changes

This commit is contained in:
zipg authored and GitHub committed 2026-08-06 20:13:59 +08:00
1 parent 575d87c022
commit 89a35d6e02
29 files changed
+1125 -65

No files matched your search

@@ -208,12 +208,12 @@ function collectDirPaths(entries: SqlFileEntry[], into: Set<string>) {
async function openFile(path: string) {
if (!isTauriRuntime()) return;
try {
const content = await api.readExternalSqlFile(path);
const snapshot = await api.readExternalSqlFileSnapshot(path);
const connectionId = connectionStore.activeConnectionId || connectionStore.connections[0]?.id || "";
const connection = connectionId ? connectionStore.getConfig(connectionId) : undefined;
const database = connection ? resolveDefaultDatabase(connection, []) : "";
const target = resolveExternalSqlFileTarget(path, (savedConnectionId) => !!connectionStore.getConfig(savedConnectionId), { connectionId, database });
queryStore.openExternalSqlFile(target.connectionId, target.database, path, content);
queryStore.openExternalSqlFile(target.connectionId, target.database, path, snapshot.content, snapshot.version);
} catch (e: any) {
if (isExternalSqlFileTooLargeError(e)) {
executeFile(path);