mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Fixed uploading zip files in import job
no issue Zip files involved a call to `await`, which caused the microtask queue to be processed. The zip file is deleted during this time because the request has already completed.
This commit is contained in:
parent
d0c2af7a15
commit
6a17b684ec
2 changed files with 13 additions and 4 deletions
|
@ -402,11 +402,21 @@ class ImportManager {
|
|||
* @returns {Promise<Object.<string, ImportResult>>}
|
||||
*/
|
||||
async importFromFile(file, importOptions = {}) {
|
||||
let importData;
|
||||
if (importOptions.data) {
|
||||
importData = importOptions.data;
|
||||
} else {
|
||||
// Step 1: Handle converting the file to usable data
|
||||
// Has to be completed outside of job to ensure file is processed before being deleted
|
||||
importData = await this.loadFile(file);
|
||||
}
|
||||
|
||||
const env = config.get('env');
|
||||
if (!env?.startsWith('testing') && !importOptions.runningInJob) {
|
||||
return jobManager.addJob({
|
||||
job: () => this.importFromFile(file, Object.assign({}, importOptions, {
|
||||
runningInJob: true
|
||||
runningInJob: true,
|
||||
data: importData
|
||||
})),
|
||||
offloaded: false
|
||||
});
|
||||
|
@ -414,9 +424,6 @@ class ImportManager {
|
|||
|
||||
let importResult;
|
||||
try {
|
||||
// Step 1: Handle converting the file to usable data
|
||||
let importData = await this.loadFile(file);
|
||||
|
||||
// Step 2: Let the importers pre-process the data
|
||||
importData = await this.preProcess(importData);
|
||||
|
||||
|
@ -462,6 +469,7 @@ class ImportManager {
|
|||
* @property {Object} [user]
|
||||
* @property {string} [user.email]
|
||||
* @property {string} [importTag]
|
||||
* @property {Object} [data]
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ class Base {
|
|||
this.options = options;
|
||||
this.modelName = options.modelName;
|
||||
|
||||
// Problems are currently constructed but not displayed to the user
|
||||
this.problems = [];
|
||||
this.errors = [];
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue