mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
fix: restore backup import after skills migration (#2980)
This commit is contained in:
+11
-3
@@ -2120,14 +2120,22 @@ function initBackup() {
|
||||
const btn = el('adm-importDataBtn');
|
||||
btn.disabled = true; btn.textContent = 'Importing...'; msg.textContent = '';
|
||||
try {
|
||||
const text = await file.text();
|
||||
const data = JSON.parse(text);
|
||||
const text = (await file.text()).replace(/^\uFEFF/, '').trim();
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(text);
|
||||
} catch (e) {
|
||||
throw new Error('Invalid backup file: ' + e.message);
|
||||
}
|
||||
const res = await fetch('/api/import', {
|
||||
method: 'POST', credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
const result = await res.json();
|
||||
const result = await res.json().catch(() => null);
|
||||
if (!result) {
|
||||
throw new Error(`Import failed: server returned ${res.status}`);
|
||||
}
|
||||
if (res.ok && result.ok) {
|
||||
msg.textContent = result.message || 'Import successful.'; msg.className = 'admin-success';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user