fix: small adjustments before v0.5

This commit is contained in:
Vasily Zubarev
2025-04-04 11:39:02 +02:00
parent fd6b5632cd
commit 1d53434f94
8 changed files with 27 additions and 21 deletions

View File

@@ -30,11 +30,6 @@ export async function restoreBackupAction(prevState: any, formData: FormData) {
return { success: false, error: "Bad zip archive" }
}
if (REMOVE_EXISTING_DATA) {
await cleanupUserTables(user.id)
await fs.rm(userUploadsDirectory, { recursive: true, force: true })
}
// Check metadata and start restoring
try {
const metadataFile = zip.file("data/metadata.json")
@@ -58,6 +53,12 @@ export async function restoreBackupAction(prevState: any, formData: FormData) {
console.warn("No metadata found in backup, assuming legacy format")
}
// Remove existing data
if (REMOVE_EXISTING_DATA) {
await cleanupUserTables(user.id)
await fs.rm(userUploadsDirectory, { recursive: true, force: true })
}
const counters: Record<string, number> = {}
// Restore tables

View File

@@ -31,22 +31,25 @@ export default function BackupSettingsPage() {
<Card className="flex flex-col gap-2 mt-16 p-5 bg-red-100 max-w-xl">
<h2 className="text-xl font-semibold">Restore from a backup</h2>
<p className="text-sm text-muted-foreground">
This action will delete all existing data from your current database and remove all uploaded files. Be
careful and make a backup first!
This action is irreversible. Restoring from a backup will delete all existing data from your current
database and remove all uploaded files. Be careful and make a backup first!
</p>
<form action={restoreBackup}>
<div className="flex flex-col gap-4 pt-4">
<input type="hidden" name="removeExistingData" value="true" />
<label>
<input type="file" name="file" />
<input type="file" name="file" required />
</label>
<label className="flex flex-row gap-2 items-center">
<input type="checkbox" name="removeExistingData" required />
<span className="text-red-500">I undestand that it will permanently delete all existing data</span>
</label>
<Button type="submit" variant="destructive" disabled={restorePending}>
{restorePending ? (
<>
<Loader2 className="animate-spin" /> Restoring from backup...
<Loader2 className="animate-spin" /> Restoring from backup... (it can take a while)
</>
) : (
"Delete existing data and restore from backup"
"Restore from backup"
)}
</Button>
</div>