Skip to content

Commit

Permalink
feat: expose restore failure reasons
Browse files Browse the repository at this point in the history
• Exposes the reason for a restore failure when available instead of using a generic error.
• Prompts users to start a site if they attempt to restore before starting.
  • Loading branch information
nickcernis committed Dec 22, 2023
1 parent 3aae537 commit 035c2c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/main/services/restoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,18 @@ export const restoreFromBackup = async (opts: {
snapshotID: string;
repoID?: string;
}): Promise<null | ErrorState> => {
const { site, provider, snapshotID, repoID } = opts;

if (serviceState.inProgressStateMachine) {
logger.warn('Restore process aborted: only one backup or restore process is allowed at one time and a backup or restore is already in progress.');
return Promise.reject('Restore process aborted: only one backup or restore process is allowed at one time and a backup or restore is already in progress.');
}

const { site, provider, snapshotID, repoID } = opts;
if (siteProcessManager.getSiteStatus(site) !== 'running') {
logger.info('Restore process aborted: site is not running.');
return Promise.reject('Please start the site before restoring a backup.');
}

return new Promise((resolve, reject) => {
const initialSiteStatus = siteProcessManager.getSiteStatus(site);

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/store/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ const restoreSite = createAsyncThunk<
],
siteId,
rejectWithValue,
(details) => {
(details, response) => {
if (details.isErrorAndUncaptured) {
showSiteBanner({
icon: 'warning',
id: details.bannerId,
message: `There was an error while restoring your backup.`,
message: response?.error?.message || 'There was an error while restoring your backup.',
siteID: details.siteId,
title: 'Cloud Backup restore failed!',
variant: 'error',
Expand Down

0 comments on commit 035c2c3

Please sign in to comment.