mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -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>>}
|
* @returns {Promise<Object.<string, ImportResult>>}
|
||||||
*/
|
*/
|
||||||
async importFromFile(file, importOptions = {}) {
|
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');
|
const env = config.get('env');
|
||||||
if (!env?.startsWith('testing') && !importOptions.runningInJob) {
|
if (!env?.startsWith('testing') && !importOptions.runningInJob) {
|
||||||
return jobManager.addJob({
|
return jobManager.addJob({
|
||||||
job: () => this.importFromFile(file, Object.assign({}, importOptions, {
|
job: () => this.importFromFile(file, Object.assign({}, importOptions, {
|
||||||
runningInJob: true
|
runningInJob: true,
|
||||||
|
data: importData
|
||||||
})),
|
})),
|
||||||
offloaded: false
|
offloaded: false
|
||||||
});
|
});
|
||||||
|
@ -414,9 +424,6 @@ class ImportManager {
|
||||||
|
|
||||||
let importResult;
|
let importResult;
|
||||||
try {
|
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
|
// Step 2: Let the importers pre-process the data
|
||||||
importData = await this.preProcess(importData);
|
importData = await this.preProcess(importData);
|
||||||
|
|
||||||
|
@ -462,6 +469,7 @@ class ImportManager {
|
||||||
* @property {Object} [user]
|
* @property {Object} [user]
|
||||||
* @property {string} [user.email]
|
* @property {string} [user.email]
|
||||||
* @property {string} [importTag]
|
* @property {string} [importTag]
|
||||||
|
* @property {Object} [data]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Base {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.modelName = options.modelName;
|
this.modelName = options.modelName;
|
||||||
|
|
||||||
|
// Problems are currently constructed but not displayed to the user
|
||||||
this.problems = [];
|
this.problems = [];
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue