feat: import private content from external bundles
This commit is contained in:
@@ -29,14 +29,17 @@ async function main() {
|
||||
if (!argument || !target) throw new Error('Usage: restore BACKUP_DIRECTORY NEW_DATA_DIRECTORY');
|
||||
restore(argument, target); console.log('Restored into the new directory. Stop the app before switching its data volume.'); return;
|
||||
}
|
||||
if (!['init', 'create-owner', 'reset-password', 'import-legacy', 'backup'].includes(command)) throw new Error('Commands: init, create-owner, reset-password, import-legacy, backup DIRECTORY, restore BACKUP_DIRECTORY NEW_DATA_DIRECTORY');
|
||||
if (!['init', 'create-owner', 'create-user', 'reset-password', 'import-legacy', 'migrate-legacy-media', 'backup'].includes(command)) throw new Error('Commands: init, create-owner (alias: create-user), reset-password, import-legacy BUNDLE_DIRECTORY, migrate-legacy-media BUNDLE_DIRECTORY, backup DIRECTORY, restore BACKUP_DIRECTORY NEW_DATA_DIRECTORY');
|
||||
const connection = initialize();
|
||||
try {
|
||||
if (command === 'create-owner' || command === 'reset-password') {
|
||||
if (command === 'create-owner' || command === 'create-user' || command === 'reset-password') {
|
||||
const { email, password } = await credentials();
|
||||
await withContentLock(() => provisionOwner(connection, email, password, command === 'reset-password'));
|
||||
console.log(command === 'create-owner' ? 'Owner created.' : 'Password updated. All sessions revoked.');
|
||||
} else if (command === 'import-legacy') { await withContentLock(() => importLegacy(connection)); console.log('Existing portfolio imported.'); }
|
||||
console.log(command === 'reset-password' ? 'Password updated. All sessions revoked.' : 'Owner created.');
|
||||
} else if (command === 'import-legacy' || command === 'migrate-legacy-media') {
|
||||
await withContentLock(() => importLegacy(connection, argument, command === 'migrate-legacy-media'));
|
||||
console.log(command === 'import-legacy' ? 'Portfolio imported.' : 'Legacy media references migrated; content preserved.');
|
||||
}
|
||||
else if (command === 'backup') { if (!argument) throw new Error('Supply a new backup directory'); await backup(connection, dataDirectory(), argument); console.log('Backup complete.'); }
|
||||
else console.log('Database initialized.');
|
||||
} finally { connection.sqlite.close(); }
|
||||
|
||||
Reference in New Issue
Block a user