feat(settings): configure SQL file size limits
This commit is contained in:
34 files changed
+554
-79
No files matched your search
@@ -4,6 +4,8 @@ import * as api from "@/lib/backend/api";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import { externalSqlFileContentMatchesBaseline, externalSqlFileMetadataMatches, externalSqlFileVersionWasIgnored } from "@/lib/sql/externalSqlFileChanges";
|
||||
import { useQueryStore } from "@/stores/queryStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { externalSqlEditorMaxBytes } from "@/lib/sql/sqlFileOpen";
|
||||
import type { ExternalSqlFileSnapshot } from "@/lib/backend/tauri";
|
||||
import type { QueryTab } from "@/types/database";
|
||||
|
||||
@@ -64,6 +66,7 @@ function delay(ms: number) {
|
||||
export function useExternalSqlFileChanges(options: UseExternalSqlFileChangesOptions) {
|
||||
const { t } = useI18n();
|
||||
const queryStore = useQueryStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const pendingPrompt = ref<ExternalSqlFilePrompt | null>(null);
|
||||
const checkingTabIds = new Set<string>();
|
||||
let promptResolver: ((decision: ExternalSqlFilePromptDecision) => void) | null = null;
|
||||
@@ -83,12 +86,13 @@ export function useExternalSqlFileChanges(options: UseExternalSqlFileChangesOpti
|
||||
}
|
||||
|
||||
async function readStableSnapshot(path: string) {
|
||||
const maxSizeBytes = externalSqlEditorMaxBytes(settingsStore.editorSettings.externalSqlEditorMaxMb);
|
||||
try {
|
||||
return await api.readExternalSqlFileSnapshot(path);
|
||||
return await api.readExternalSqlFileSnapshot(path, maxSizeBytes);
|
||||
} catch (firstError) {
|
||||
await delay(MISSING_FILE_RECHECK_DELAY_MS);
|
||||
try {
|
||||
return await api.readExternalSqlFileSnapshot(path);
|
||||
return await api.readExternalSqlFileSnapshot(path, maxSizeBytes);
|
||||
} catch {
|
||||
throw firstError;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ import { uuid } from "@/lib/common/utils";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useQueryStore } from "@/stores/queryStore";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { useLargeSqlFileStreamingFallback } from "@/composables/useLargeSqlFileFallback";
|
||||
import * as api from "@/lib/backend/api";
|
||||
import type { ConnectionConfig, ExternalSqlFileVersion } from "@/types/database";
|
||||
import { detectDatabaseFileType } from "@/lib/database/databaseFileDetection";
|
||||
import { externalSqlFileOpenErrorMessage, readBrowserSqlFile } from "@/lib/sql/sqlFileOpen";
|
||||
import { externalSqlEditorMaxBytes, externalSqlFileOpenErrorMessage, readBrowserSqlFile } from "@/lib/sql/sqlFileOpen";
|
||||
import { resolveExternalSqlFileTarget, unassociatedExternalSqlFileTarget } from "@/lib/sql/externalSqlFileTarget";
|
||||
|
||||
function isSqlFilePath(path: string): boolean {
|
||||
@@ -23,6 +24,7 @@ export function useFileDrop() {
|
||||
const { t } = useI18n();
|
||||
const connectionStore = useConnectionStore();
|
||||
const queryStore = useQueryStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const { toast } = useToast();
|
||||
const { openInStreamingExecutorOnTooLarge } = useLargeSqlFileStreamingFallback();
|
||||
|
||||
@@ -87,7 +89,7 @@ export function useFileDrop() {
|
||||
|
||||
if (isSqlFilePath(path)) {
|
||||
try {
|
||||
const snapshot = await api.readExternalSqlFileSnapshot(path);
|
||||
const snapshot = await api.readExternalSqlFileSnapshot(path, externalSqlEditorMaxBytes(settingsStore.editorSettings.externalSqlEditorMaxMb));
|
||||
await openDroppedSqlFile(name, snapshot.content, path, snapshot.version);
|
||||
} catch (e: any) {
|
||||
if (!openInStreamingExecutorOnTooLarge(path, e)) {
|
||||
@@ -128,7 +130,7 @@ export function useFileDrop() {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
if (!isSqlFilePath(file.name)) continue;
|
||||
void readBrowserSqlFile(file)
|
||||
void readBrowserSqlFile(file, externalSqlEditorMaxBytes(settingsStore.editorSettings.externalSqlEditorMaxMb))
|
||||
.then((content) => openDroppedSqlFile(file.name, content))
|
||||
.catch((e: any) => {
|
||||
toast(t("toolbar.sqlOpenFailed", { message: externalSqlFileOpenErrorMessage(e, (key, params) => t(key, params)) }), 5000);
|
||||
|
||||
Reference in new issue
Block a user