fix(sqlite): validate ssh backup and query errors
This commit is contained in:
1 parent
e6f8b2187a
commit
9190554e50
58 files changed
+2815
-149
No files matched your search
@@ -214,7 +214,6 @@ export function useSidebarConnectionMutationRuntime(options: SidebarConnectionMu
|
||||
|
||||
async function disconnectConnectionIds(connectionIds: readonly string[]) {
|
||||
if (!connectionIds.length) return;
|
||||
|
||||
const result = await disconnectSidebarConnections(connectionIds, (connectionId) => connectionStore.disconnect(connectionId));
|
||||
if (!result.failed) {
|
||||
toast(connectionIds.length > 1 ? t("connection.disconnectedSelected", { count: connectionIds.length }) : t("connection.disconnected"), 2000);
|
||||
@@ -228,6 +227,28 @@ export function useSidebarConnectionMutationRuntime(options: SidebarConnectionMu
|
||||
toast(t("connection.saveFailed", { message }), 5000);
|
||||
}
|
||||
|
||||
async function restoreSqliteDatabase() {
|
||||
const connectionId = activeNode.value.connectionId;
|
||||
const config = connectionId ? connectionStore.getConfig(connectionId) : undefined;
|
||||
if (!connectionId || !config) return;
|
||||
const usesSsh = (config.transport_layers || []).some((layer) => layer.enabled !== false && layer.type === "ssh");
|
||||
if (!usesSsh) return;
|
||||
const { open } = await import("@tauri-apps/plugin-dialog");
|
||||
const sourcePath = await open({
|
||||
multiple: false,
|
||||
filters: [{ name: "SQLite", extensions: ["db", "sqlite", "sqlite3", "bak"] }],
|
||||
});
|
||||
if (typeof sourcePath !== "string" || !sourcePath) return;
|
||||
try {
|
||||
toast(t("contextMenu.restoreSqliteDatabaseInProgress"), 2000);
|
||||
await connectionStore.ensureConnected(connectionId);
|
||||
await api.restoreSqliteDatabase(connectionId, sourcePath);
|
||||
toast(t("contextMenu.restoreSqliteDatabaseSuccess"), 3000);
|
||||
} catch (error: any) {
|
||||
toast(t("contextMenu.restoreSqliteDatabaseFailed", { message: error?.message || String(error) }), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
async function disconnectConnection() {
|
||||
const connectionIds = selectedConnectionDisconnectTargets(activeNode.value, selectedTreeNodesInVisibleOrder())
|
||||
.filter((target) => connectionStore.connectedIds.has(target.connectionId))
|
||||
@@ -444,6 +465,7 @@ export function useSidebarConnectionMutationRuntime(options: SidebarConnectionMu
|
||||
sqliteBackupSource,
|
||||
canBackupSqliteDatabase,
|
||||
backupSqliteDatabase,
|
||||
restoreSqliteDatabase,
|
||||
disconnectConnection,
|
||||
connectionDisconnectMenuLabel,
|
||||
canDisconnectConnection,
|
||||
|
||||
Reference in new issue
Block a user