mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
Confirm continuing the transfer process if assets backup fakls
This commit is contained in:
parent
999ff029f0
commit
d04d944fcd
@ -27,6 +27,7 @@ import type {
|
||||
SchemaDiffHandler,
|
||||
SchemaDiffHandlerContext,
|
||||
AssetsBackupErrorHandler,
|
||||
AssetsBackupErrorHandlerContext,
|
||||
} from '../../types';
|
||||
import type { Diff } from '../utils/json';
|
||||
|
||||
@ -749,9 +750,20 @@ class TransferEngine<
|
||||
|
||||
async beforeTransfer(): Promise<void> {
|
||||
const runWithDiagnostic = async (provider: IProvider) => {
|
||||
const context: AssetsBackupErrorHandlerContext = {};
|
||||
|
||||
try {
|
||||
await provider.beforeTransfer?.();
|
||||
} catch (error) {
|
||||
await utils.middleware.runMiddleware<AssetsBackupErrorHandlerContext>(
|
||||
context,
|
||||
this.#handlers.assetsBackupError
|
||||
);
|
||||
console.log('context', context);
|
||||
if (context.ignore) {
|
||||
console.log('Entering here');
|
||||
return;
|
||||
}
|
||||
// Error happening during the before transfer step should be considered fatal errors
|
||||
if (error instanceof Error) {
|
||||
this.panic(error);
|
||||
|
@ -18,7 +18,11 @@ export type SchemaDiffHandlerContext = {
|
||||
};
|
||||
export type SchemaDiffHandler = Middleware<SchemaDiffHandlerContext>;
|
||||
|
||||
export type AssetsBackupErrorHandler = Middleware;
|
||||
export type AssetsBackupErrorHandlerContext = {
|
||||
ignore?: boolean;
|
||||
};
|
||||
|
||||
export type AssetsBackupErrorHandler = Middleware<AssetsBackupErrorHandlerContext>;
|
||||
|
||||
/**
|
||||
* Defines the capabilities and properties of the transfer engine
|
||||
|
@ -349,16 +349,19 @@ const getAssetsBackupHandler = (engine, { force, action }) => {
|
||||
exitWith(1, exitMessageText(action, true));
|
||||
});
|
||||
|
||||
await confirmMessage(
|
||||
'There are differences in schema between the source and destination, and the data listed above will be lost. Are you sure you want to continue?',
|
||||
const confirmed = await confirmMessage(
|
||||
'The backup folder for the assets could not be created inside the public folder. Maybe Strapi does not have write permissions on the public directory. Do you want to continue without the backup?',
|
||||
{
|
||||
force,
|
||||
}
|
||||
);
|
||||
|
||||
if (confirmed) {
|
||||
context.ignore = true;
|
||||
}
|
||||
|
||||
// reset handler back to normal
|
||||
setSignalHandler(() => abortTransfer({ engine, strapi }));
|
||||
|
||||
return next(context);
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user