mirror of
https://github.com/strapi/strapi.git
synced 2025-12-13 07:55:33 +00:00
Merge pull request #15283 from strapi/deits/validate-file-before-restore
This commit is contained in:
commit
11854540ed
@ -159,7 +159,7 @@ class TransferEngine<
|
||||
});
|
||||
}
|
||||
|
||||
#emitTransferUpdate(type: 'start' | 'finish' | 'error', payload?: object) {
|
||||
#emitTransferUpdate(type: 'init' | 'start' | 'finish' | 'error', payload?: object) {
|
||||
this.progress.stream.emit(`transfer::${type}`, payload);
|
||||
}
|
||||
|
||||
@ -336,9 +336,8 @@ class TransferEngine<
|
||||
// reset data between transfers
|
||||
this.progress.data = {};
|
||||
|
||||
this.#emitTransferUpdate('start');
|
||||
|
||||
try {
|
||||
this.#emitTransferUpdate('init');
|
||||
await this.bootstrap();
|
||||
await this.init();
|
||||
|
||||
@ -351,6 +350,8 @@ class TransferEngine<
|
||||
);
|
||||
}
|
||||
|
||||
this.#emitTransferUpdate('start');
|
||||
|
||||
await this.beforeTransfer();
|
||||
|
||||
// Run the transfer stages
|
||||
|
||||
@ -49,6 +49,8 @@ class LocalFileSourceProvider implements ISourceProvider {
|
||||
|
||||
options: ILocalFileSourceProviderOptions;
|
||||
|
||||
#metadata?: IMetadata;
|
||||
|
||||
constructor(options: ILocalFileSourceProviderOptions) {
|
||||
this.options = options;
|
||||
|
||||
@ -60,15 +62,16 @@ class LocalFileSourceProvider implements ISourceProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre flight checks regarding the provided options (making sure that the provided path is correct, etc...)
|
||||
* Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
|
||||
*/
|
||||
async bootstrap() {
|
||||
const { path: filePath } = this.options.file;
|
||||
|
||||
try {
|
||||
// This is only to show a nicer error, it doesn't ensure the file will still exist when we try to open it later
|
||||
await fs.access(filePath, fs.constants.R_OK);
|
||||
// Read the metadata to ensure the file can be parsed
|
||||
this.#metadata = await this.getMetadata();
|
||||
} catch (e) {
|
||||
throw new Error(`Can't access file "${filePath}".`);
|
||||
throw new Error(`Can't read file "${filePath}".`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -74,8 +74,6 @@ module.exports = async (opts) => {
|
||||
},
|
||||
});
|
||||
|
||||
logger.log(`Starting export...`);
|
||||
|
||||
const progress = engine.progress.stream;
|
||||
|
||||
const getTelemetryPayload = (/* payload */) => {
|
||||
@ -88,6 +86,7 @@ module.exports = async (opts) => {
|
||||
};
|
||||
|
||||
progress.on('transfer::start', async () => {
|
||||
logger.log(`Starting export...`);
|
||||
await strapi.telemetry.send('didDEITSProcessStart', getTelemetryPayload());
|
||||
});
|
||||
|
||||
|
||||
@ -77,9 +77,8 @@ module.exports = async (opts) => {
|
||||
],
|
||||
},
|
||||
};
|
||||
const engine = createTransferEngine(source, destination, engineOptions);
|
||||
|
||||
logger.info('Starting import...');
|
||||
const engine = createTransferEngine(source, destination, engineOptions);
|
||||
|
||||
const progress = engine.progress.stream;
|
||||
const getTelemetryPayload = () => {
|
||||
@ -92,6 +91,7 @@ module.exports = async (opts) => {
|
||||
};
|
||||
|
||||
progress.on('transfer::start', async () => {
|
||||
logger.info('Starting import...');
|
||||
await strapiInstance.telemetry.send('didDEITSProcessStart', getTelemetryPayload());
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user