diff --git a/backend/prisma/dev.db.backup b/backend/prisma/dev.db.backup new file mode 100644 index 0000000..f654238 Binary files /dev/null and b/backend/prisma/dev.db.backup differ diff --git a/backend/src/index.ts b/backend/src/index.ts index 169ebe4..cea22bf 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -99,9 +99,14 @@ const upload = multer({ files: 1, // Only one file per upload }, fileFilter: (req, file, cb) => { - // Only allow .db files for SQLite imports - if (file.fieldname === "db" && !file.originalname.endsWith(".db")) { - return cb(new Error("Only .db files are allowed")); + // Only allow SQLite database extensions for database imports + if (file.fieldname === "db") { + const isSqliteDb = + file.originalname.endsWith(".db") || + file.originalname.endsWith(".sqlite"); + if (!isSqliteDb) { + return cb(new Error("Only .db or .sqlite files are allowed")); + } } cb(null, true); }, @@ -775,9 +780,14 @@ app.delete("/collections/:id", async (req, res) => { // --- Export/Import Endpoints --- -// GET /export - Export SQLite database +// GET /export - Export SQLite database (supports .sqlite and .db extensions) app.get("/export", async (req, res) => { try { + const formatParam = + typeof req.query.format === "string" + ? req.query.format.toLowerCase() + : undefined; + const extension = formatParam === "db" ? "db" : "sqlite"; const dbPath = path.resolve(__dirname, "../prisma/dev.db"); try { @@ -791,7 +801,7 @@ app.get("/export", async (req, res) => { "Content-Disposition", `attachment; filename="excalidash-db-${ new Date().toISOString().split("T")[0] - }.sqlite"` + }.${extension}"` ); const fileStream = fs.createReadStream(dbPath); diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 7b62582..314d0c3 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -3,7 +3,7 @@ import { Layout } from '../components/Layout'; import { useNavigate } from 'react-router-dom'; import * as api from '../api'; import type { Collection } from '../types'; -import { Database, FileJson, Upload, Moon, Sun, Info } from 'lucide-react'; +import { Database, FileJson, Upload, Moon, Sun, Info, HardDrive } from 'lucide-react'; import { ConfirmModal } from '../components/ConfirmModal'; import { importDrawings } from '../utils/importUtils'; import { useTheme } from '../context/ThemeContext'; @@ -94,7 +94,7 @@ export const Settings: React.FC = () => { - {/* Export SQLite */} + {/* Export SQLite (.sqlite) */} + {/* Export SQLite (.db) */} + + {/* Export JSON */}