mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-16 08:55:18 +00:00
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:
@@ -547,7 +547,7 @@ export const backupRouter = createTRPCRouter({
|
|||||||
const queue: string[] = [];
|
const queue: string[] = [];
|
||||||
let done = false;
|
let done = false;
|
||||||
const onLog = (log: string) => queue.push(log);
|
const onLog = (log: string) => queue.push(log);
|
||||||
(async () => {
|
const runRestore = async () => {
|
||||||
if (input.backupType === "database") {
|
if (input.backupType === "database") {
|
||||||
if (input.databaseType === "postgres") {
|
if (input.databaseType === "postgres") {
|
||||||
const postgres = await findPostgresById(input.databaseId);
|
const postgres = await findPostgresById(input.databaseId);
|
||||||
@@ -571,8 +571,13 @@ export const backupRouter = createTRPCRouter({
|
|||||||
const compose = await findComposeById(input.databaseId);
|
const compose = await findComposeById(input.databaseId);
|
||||||
await restoreComposeBackup(compose, destination, input, onLog);
|
await restoreComposeBackup(compose, destination, input, onLog);
|
||||||
}
|
}
|
||||||
})()
|
};
|
||||||
.catch(() => {})
|
runRestore()
|
||||||
|
.catch((error) => {
|
||||||
|
onLog(
|
||||||
|
`Error: ${error instanceof Error ? error.message : String(error)}`,
|
||||||
|
);
|
||||||
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
done = true;
|
done = true;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user