Code listing (detail) of index.page.js in Helix Editor: const RestoreStatusUpdate = ({SLOT}) => kitten.html` <div id='restore-status' class='progress'> <${ProgressIndicator} /> ${SLOT} </div> ` export function onConnect ({request, page}) { page.on('startRestore', () => { page.send(kitten.html`<${RestoreStatusUpdate}>Uploading backup to restore from…</>`) }) const restoreDatabases = async (/** @type {Upload} */ upload) => { console.log('Restore: database backup uploaded', upload) // Show status indicator. page.send(kitten.html`<${RestoreStatusUpdate}>Restoring from backup…</>`) // Delete current databases. const deleteResult = await fs.rm(kitten.databaseDirectory, {recursive: true, force: true}) // Re-create databases directory. const makeDirectoryResult = await fs.mkdir(kitten.databaseDirectory) // Decompress backed-up databases. await extract({ cwd: kitten.databaseDirectory, file: upload.filePath }) // Send refresh header and restart the server so the // restored databases are loaded into memory. page.send(kitten.html`<${RestoreStatusUpdate}>Restore complete, waiting for server restart…`) // Restart the server. process.exit(99 /* code for restart request */) } request.session.removeListener('databasesUploadedForRestore', restoreDatabases) request.session.addListener('databasesUploadedForRestore', restoreDatabases)
https://s3-eu-central-1.amazonaws.com/mastodon-aral/media_attachments/files/112/383/600/481/486/638/original/a61cee66dc0a4ca4.png