feat(backup): support cross-platform background database backups
This commit is contained in:
1 parent
250e0c0a10
commit
2f960f104c
56 files changed
+4195
-962
No files matched your search
@@ -39,6 +39,7 @@ const props = defineProps<{
|
||||
prefillConnectionId?: string;
|
||||
prefillDatabase?: string;
|
||||
prefillFilePath?: string;
|
||||
prefillPreview?: SqlFilePreview;
|
||||
}>();
|
||||
|
||||
const store = useConnectionStore();
|
||||
@@ -239,6 +240,7 @@ watch(canUseManualTransaction, (supported) => {
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
disposed = true;
|
||||
if (!running.value) void releaseManagedPreviews();
|
||||
if (running.value && manualTransaction.value) {
|
||||
cancelRequested.value = true;
|
||||
if (executionStarted.value) void cancelSqlFileExecution(executionId.value).catch(() => {});
|
||||
@@ -469,6 +471,7 @@ async function previewSelectedSqlFile(fileOrPath: string | File) {
|
||||
|
||||
async function loadPreviews(filesOrPaths: Array<string | File>) {
|
||||
if (executionLocked.value) return;
|
||||
await releaseManagedPreviews();
|
||||
loadingPreview.value = true;
|
||||
previews.value = [];
|
||||
resetExecution();
|
||||
@@ -485,6 +488,18 @@ async function loadPreviews(filesOrPaths: Array<string | File>) {
|
||||
}
|
||||
}
|
||||
|
||||
async function releaseManagedPreviews() {
|
||||
const tokens = previews.value.flatMap((preview) => (preview.cleanupToken ? [preview.cleanupToken] : []));
|
||||
if (!tokens.length) return;
|
||||
previews.value = previews.value.filter((preview) => !preview.cleanupToken);
|
||||
try {
|
||||
const { releaseSqlFilePreview } = await import("@/lib/backend/api");
|
||||
await Promise.all(tokens.map((token) => releaseSqlFilePreview(token)));
|
||||
} catch (error: any) {
|
||||
toast(error?.message || String(error), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
async function selectFile() {
|
||||
if (executionLocked.value) return;
|
||||
if (!isTauriRuntime()) {
|
||||
@@ -721,6 +736,7 @@ async function startExecution() {
|
||||
running.value = false;
|
||||
cancelling.value = false;
|
||||
executionStarted.value = false;
|
||||
await releaseManagedPreviews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,6 +779,7 @@ watch(
|
||||
open,
|
||||
(value) => {
|
||||
if (!value) {
|
||||
if (!running.value) void releaseManagedPreviews();
|
||||
if (manualTransaction.value && running.value) void cancelExecution();
|
||||
else if (txnSessionId.value) void finishTransaction(false);
|
||||
return;
|
||||
@@ -774,7 +791,9 @@ watch(
|
||||
}
|
||||
// When opened from the SQL Files panel with a pre-selected file, load its
|
||||
// preview automatically so the user can review statements before running.
|
||||
if (props.prefillFilePath) {
|
||||
if (props.prefillPreview) {
|
||||
previews.value = [props.prefillPreview];
|
||||
} else if (props.prefillFilePath) {
|
||||
void loadPreviews([props.prefillFilePath]);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user