refactor(backup): rename async function for clarity and improve error logging

- Changed the anonymous async function to a named function `runRestore` for better readability.
- Enhanced error handling to log specific error messages during the restore process.
This commit is contained in:
Mauricio Siu
2026-04-03 15:13:09 -06:00
parent 5978c4135e
commit df95766807

View File

@@ -547,7 +547,7 @@ export const backupRouter = createTRPCRouter({
const queue: string[] = [];
let done = false;
const onLog = (log: string) => queue.push(log);
(async () => {
const runRestore = async () => {
if (input.backupType === "database") {
if (input.databaseType === "postgres") {
const postgres = await findPostgresById(input.databaseId);
@@ -571,8 +571,13 @@ export const backupRouter = createTRPCRouter({
const compose = await findComposeById(input.databaseId);
await restoreComposeBackup(compose, destination, input, onLog);
}
})()
.catch(() => {})
};
runRestore()
.catch((error) => {
onLog(
`Error: ${error instanceof Error ? error.message : String(error)}`,
);
})
.finally(() => {
done = true;
});