mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
remove sqlite
This commit is contained in:
@@ -40,7 +40,6 @@ const defaultValuesForType = {
|
||||
mariadb: { backend: "mariadb" as const, port: 3306 },
|
||||
mysql: { backend: "mysql" as const, port: 3306 },
|
||||
postgres: { backend: "postgres" as const, port: 5432, dumpFormat: "custom" as const },
|
||||
sqlite: { backend: "sqlite" as const, path: "/" },
|
||||
};
|
||||
|
||||
export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, formId, loading, className }: Props) => {
|
||||
@@ -139,7 +138,6 @@ export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, for
|
||||
<SelectItem value="mariadb">MariaDB</SelectItem>
|
||||
<SelectItem value="mysql">MySQL</SelectItem>
|
||||
<SelectItem value="postgres">PostgreSQL</SelectItem>
|
||||
<SelectItem value="sqlite">SQLite</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormDescription>Choose the storage backend for this volume.</FormDescription>
|
||||
@@ -798,38 +796,7 @@ export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, for
|
||||
</>
|
||||
)}
|
||||
|
||||
{watchedBackend === "sqlite" && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="path"
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<FormItem>
|
||||
<FormLabel>Database File Path</FormLabel>
|
||||
<FormControl>
|
||||
{field.value ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1 border rounded-md p-3 bg-muted/50">
|
||||
<div className="text-xs font-medium text-muted-foreground mb-1">Selected database:</div>
|
||||
<div className="text-sm font-mono break-all">{field.value}</div>
|
||||
</div>
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => field.onChange("")}>
|
||||
Change
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<DirectoryBrowser onSelectPath={(path) => field.onChange(path)} selectedPath={field.value} />
|
||||
)}
|
||||
</FormControl>
|
||||
<FormDescription>Path to the SQLite database file (.db, .sqlite, .sqlite3).</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{watchedBackend !== "directory" && watchedBackend !== "sqlite" && (
|
||||
{watchedBackend !== "directory" && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
|
||||
@@ -8,7 +8,6 @@ export const BACKEND_TYPES = {
|
||||
mariadb: "mariadb",
|
||||
mysql: "mysql",
|
||||
postgres: "postgres",
|
||||
sqlite: "sqlite",
|
||||
} as const;
|
||||
|
||||
export type BackendType = keyof typeof BACKEND_TYPES;
|
||||
@@ -82,19 +81,13 @@ export const postgresConfigSchema = type({
|
||||
dumpOptions: "string[]?",
|
||||
});
|
||||
|
||||
export const sqliteConfigSchema = type({
|
||||
backend: "'sqlite'",
|
||||
path: "string",
|
||||
});
|
||||
|
||||
export const volumeConfigSchema = nfsConfigSchema
|
||||
.or(smbConfigSchema)
|
||||
.or(webdavConfigSchema)
|
||||
.or(directoryConfigSchema)
|
||||
.or(mariadbConfigSchema)
|
||||
.or(mysqlConfigSchema)
|
||||
.or(postgresConfigSchema)
|
||||
.or(sqliteConfigSchema);
|
||||
.or(postgresConfigSchema);
|
||||
|
||||
export type BackendConfig = typeof volumeConfigSchema.infer;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import { makeWebdavBackend } from "./webdav/webdav-backend";
|
||||
import { makeMariaDBBackend } from "./mariadb/mariadb-backend";
|
||||
import { makeMySQLBackend } from "./mysql/mysql-backend";
|
||||
import { makePostgresBackend } from "./postgres/postgres-backend";
|
||||
import { makeSQLiteBackend } from "./sqlite/sqlite-backend";
|
||||
|
||||
type OperationResult = {
|
||||
error?: string;
|
||||
@@ -46,9 +45,6 @@ export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||
case "postgres": {
|
||||
return makePostgresBackend(volume.config, path);
|
||||
}
|
||||
case "sqlite": {
|
||||
return makeSQLiteBackend(volume.config, path);
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported backend type: ${(volume.config as any).backend}`);
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
import * as fs from "node:fs/promises";
|
||||
import { toMessage } from "../../../utils/errors";
|
||||
import { logger } from "../../../utils/logger";
|
||||
import { testSQLiteConnection } from "../../../utils/database-dump";
|
||||
import type { VolumeBackend } from "../backend";
|
||||
import { BACKEND_STATUS, type BackendConfig } from "~/schemas/volumes";
|
||||
|
||||
const mount = async (config: BackendConfig, volumePath: string) => {
|
||||
if (config.backend !== "sqlite") {
|
||||
return { status: BACKEND_STATUS.error, error: "Invalid backend type" };
|
||||
}
|
||||
|
||||
logger.info(`Testing SQLite connection to: ${config.path}`);
|
||||
|
||||
try {
|
||||
await testSQLiteConnection(config);
|
||||
await fs.mkdir(volumePath, { recursive: true });
|
||||
|
||||
logger.info("SQLite connection successful");
|
||||
return { status: BACKEND_STATUS.mounted };
|
||||
} catch (error) {
|
||||
logger.error("Failed to access SQLite database:", error);
|
||||
return { status: BACKEND_STATUS.error, error: toMessage(error) };
|
||||
}
|
||||
};
|
||||
|
||||
const unmount = async (volumePath: string) => {
|
||||
logger.info("Cleaning up SQLite dump directory");
|
||||
|
||||
try {
|
||||
await fs.rm(volumePath, { recursive: true, force: true });
|
||||
return { status: BACKEND_STATUS.unmounted };
|
||||
} catch (error) {
|
||||
logger.warn(`Failed to clean up SQLite dump directory: ${toMessage(error)}`);
|
||||
return { status: BACKEND_STATUS.unmounted };
|
||||
}
|
||||
};
|
||||
|
||||
const checkHealth = async (config: BackendConfig) => {
|
||||
if (config.backend !== "sqlite") {
|
||||
return { status: BACKEND_STATUS.error, error: "Invalid backend type" };
|
||||
}
|
||||
|
||||
try {
|
||||
await testSQLiteConnection(config);
|
||||
return { status: BACKEND_STATUS.mounted };
|
||||
} catch (error) {
|
||||
logger.error("SQLite health check failed:", error);
|
||||
return { status: BACKEND_STATUS.error, error: toMessage(error) };
|
||||
}
|
||||
};
|
||||
|
||||
export const makeSQLiteBackend = (config: BackendConfig, volumePath: string): VolumeBackend => ({
|
||||
mount: () => mount(config, volumePath),
|
||||
unmount: () => unmount(volumePath),
|
||||
checkHealth: () => checkHealth(config),
|
||||
});
|
||||
Reference in New Issue
Block a user