Remove the V1 database importer
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 30s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 30s
The /api/import/v1 endpoint, server/services/v1import.ts and its test are
gone; Settings already restores full V2 backups in that place. MIGRATION.md
now covers V1 JSON exports and running the old importer from history
(7125dec), plus moving data between V2 installs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7125dec3e0
commit
5fef59b07b
6 changed files with 29 additions and 359 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { Hono } from 'hono';
|
||||
import { bodyLimit } from 'hono/body-limit';
|
||||
|
|
@ -12,7 +11,6 @@ import { createSnapshot, exportBundle, fullBackupStream, listBackups } from '../
|
|||
import { createClass, createDeck, createFolder, createNote, createQuiz, draftCardToInput, draftQuestionToInput, getClass, getDeck, getQuiz, listCards, listQuestions } from '../services/content.ts';
|
||||
import { createTemplate, deleteTemplate, listTemplates, resetTemplate, templateInputSchema, updateTemplate } from '../services/templates.ts';
|
||||
import { restoreFullBackup } from '../services/restore.ts';
|
||||
import { importV1 } from '../services/v1import.ts';
|
||||
import { sessionHash } from '../auth.ts';
|
||||
import { slugify } from '../util.ts';
|
||||
|
||||
|
|
@ -215,29 +213,6 @@ export function dataRoutes(app: AppContext): Hono {
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Migration from a V1 database file. `?preview=1` only reports what would be imported. Not in
|
||||
* Settings any more (full-backup restore took its place); see docs/MIGRATION.md.
|
||||
*/
|
||||
r.post('/import/v1', bodyLimit({ maxSize: 500 * 1024 * 1024 }), async (c) => {
|
||||
const form = await c.req.parseBody().catch(() => {
|
||||
throw badRequest('Upload could not be read');
|
||||
});
|
||||
const file = form.file;
|
||||
if (!file || typeof file === 'string') throw badRequest('Choose your V1 study.db file');
|
||||
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||
if (new TextDecoder().decode(bytes.subarray(0, 15)) !== 'SQLite format 3') throw badRequest('That file is not a SQLite database.');
|
||||
const tmp = path.join(os.tmpdir(), `studydesk-v1-${Date.now()}-${Math.random().toString(36).slice(2)}.db`);
|
||||
fs.writeFileSync(tmp, bytes);
|
||||
try {
|
||||
const preview = c.req.query('preview') === '1';
|
||||
if (!preview) createSnapshot(app, 'pre-v1-import');
|
||||
return c.json({ preview, summary: importV1(app, tmp, { dryRun: preview }) });
|
||||
} finally {
|
||||
fs.rmSync(tmp, { force: true });
|
||||
}
|
||||
});
|
||||
|
||||
/* ------------------------------ export + backup ------------------------------ */
|
||||
|
||||
r.get('/export/all', (c) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue