fix(export): release db backup snapshot only on terminal state
This commit is contained in:
8 files changed
+59
-12
No files matched your search
@@ -12,7 +12,7 @@ import * as api from "@/lib/backend/api";
|
||||
import type { ExportProgress } from "@/lib/backend/api";
|
||||
import { isSchemaAware } from "@/lib/database/databaseFeatureSupport";
|
||||
import { databaseOptionsForConnection } from "@/composables/useDatabaseOptions";
|
||||
import { buildAllDatabaseExportPlan, generateDatabaseExportId, runDatabaseExportUntilTerminal, runWithDatabaseBackupSnapshot, type AllDatabaseExportPlanItem } from "@/lib/export/databaseExport";
|
||||
import { buildAllDatabaseExportPlan, generateDatabaseExportId, runDatabaseExportUntilTerminal, runWithDatabaseBackupSnapshot, shouldUseDatabaseBackupSnapshot, type AllDatabaseExportPlanItem } from "@/lib/export/databaseExport";
|
||||
import { buildSelectedTablesPayload } from "@/lib/export/databaseExportSelection";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
@@ -304,7 +304,7 @@ async function startExport() {
|
||||
{
|
||||
connectionId: connectionId.value,
|
||||
database: database.value,
|
||||
enabled: includeData.value && (connectionType === "mysql" || connectionType === "postgres"),
|
||||
enabled: shouldUseDatabaseBackupSnapshot(connectionType, includeData.value, isTauriRuntime()),
|
||||
},
|
||||
async (snapshotSessionId) => {
|
||||
const request: api.DatabaseExportRequest = {
|
||||
@@ -323,7 +323,7 @@ async function startExport() {
|
||||
snapshotSessionId,
|
||||
batchSize: 1000,
|
||||
};
|
||||
await api.exportDatabaseSql(request, (progress) => {
|
||||
return runDatabaseExportUntilTerminal(request, (progress) => {
|
||||
exportProgress.value = { ...progress };
|
||||
updateDatabaseExportTask(progress.exportId, progress);
|
||||
if (progress.status === "Done") {
|
||||
@@ -342,7 +342,7 @@ async function startExport() {
|
||||
}
|
||||
});
|
||||
},
|
||||
() => !exportError.value && !exportCancelled.value,
|
||||
(terminal) => terminal.status === "Done",
|
||||
);
|
||||
} catch (e: any) {
|
||||
exportError.value = e?.message || String(e);
|
||||
@@ -438,7 +438,7 @@ async function startAllDatabasesExport() {
|
||||
{
|
||||
connectionId: connectionId.value,
|
||||
database: item.database,
|
||||
enabled: includeData.value && (connectionType === "mysql" || connectionType === "postgres"),
|
||||
enabled: shouldUseDatabaseBackupSnapshot(connectionType, includeData.value, isTauriRuntime()),
|
||||
},
|
||||
(snapshotSessionId) =>
|
||||
runDatabaseExportUntilTerminal(
|
||||
|
||||
@@ -2423,7 +2423,7 @@ export default withEnglishFallback({
|
||||
changeOpenMode: "Modificar modo de apertura",
|
||||
closeRightTabs: "Cerrar pestañas a la derecha",
|
||||
compileObject: "Compilar",
|
||||
compileObjectSuccess: "\"{name}\" compilado con éxito",
|
||||
compileObjectSuccess: '"{name}" compilado con éxito',
|
||||
},
|
||||
visibleDatabases: {
|
||||
title: "Bases de datos visibles",
|
||||
|
||||
@@ -2421,7 +2421,7 @@ export default withEnglishFallback({
|
||||
changeOpenMode: "Modifica modalità apertura",
|
||||
closeRightTabs: "Chiudi le schede a destra",
|
||||
compileObject: "Compila",
|
||||
compileObjectSuccess: "\"{name}\" compilato con successo",
|
||||
compileObjectSuccess: '"{name}" compilato con successo',
|
||||
},
|
||||
visibleDatabases: {
|
||||
title: "Database Visibili",
|
||||
|
||||
@@ -2448,7 +2448,7 @@ export default withEnglishFallback({
|
||||
changeOpenMode: "開き方を変更",
|
||||
closeRightTabs: "右側のタブを閉じる",
|
||||
compileObject: "コンパイル",
|
||||
compileObjectSuccess: "\"{name}\" のコンパイルに成功しました",
|
||||
compileObjectSuccess: '"{name}" のコンパイルに成功しました',
|
||||
},
|
||||
visibleDatabases: {
|
||||
title: "表示するデータベース",
|
||||
|
||||
@@ -2423,7 +2423,7 @@ export default withEnglishFallback({
|
||||
changeOpenMode: "Alterar modo de abertura",
|
||||
closeRightTabs: "Fechar abas à direita",
|
||||
compileObject: "Compilar",
|
||||
compileObjectSuccess: "\"{name}\" compilado com sucesso",
|
||||
compileObjectSuccess: '"{name}" compilado com sucesso',
|
||||
},
|
||||
visibleDatabases: {
|
||||
title: "Bancos de dados visíveis",
|
||||
|
||||
@@ -2422,7 +2422,7 @@ export default withEnglishFallback({
|
||||
changeOpenMode: "修改開啟方式",
|
||||
closeRightTabs: "關閉右側標籤頁",
|
||||
compileObject: "編譯",
|
||||
compileObjectSuccess: "\"{name}\" 編譯成功",
|
||||
compileObjectSuccess: '"{name}" 編譯成功',
|
||||
},
|
||||
visibleDatabases: {
|
||||
title: "顯示資料庫",
|
||||
|
||||
@@ -93,6 +93,10 @@ export function generateDatabaseExportId(): string {
|
||||
return uuid();
|
||||
}
|
||||
|
||||
export function shouldUseDatabaseBackupSnapshot(databaseType: DatabaseType | undefined, includeData: boolean, desktopRuntime: boolean): boolean {
|
||||
return desktopRuntime && includeData && (databaseType === "mysql" || databaseType === "postgres");
|
||||
}
|
||||
|
||||
export async function runDatabaseExportUntilTerminal(request: api.DatabaseExportRequest, onProgress: (progress: api.ExportProgress) => void): Promise<api.ExportProgress> {
|
||||
return new Promise<api.ExportProgress>((resolve, reject) => {
|
||||
api
|
||||
|
||||
Reference in new issue
Block a user