mirror of
https://github.com/strapi/strapi.git
synced 2026-01-04 03:03:38 +00:00
Handle case files array to unzip is empty
This commit is contained in:
parent
5e92ba1068
commit
754abd3a5c
@ -151,63 +151,74 @@ module.exports = function (strapi) {
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
syncPromise(_.first(data.files), 0)
|
||||
.then(function () {
|
||||
if (data.hasOwnProperty('action') && _.isFunction(_self[data.action])) {
|
||||
_self[data.action](data, function (err, obj) {
|
||||
if (_.isEmpty(data.files)) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: null,
|
||||
data: stringify({}, null, 2)
|
||||
})
|
||||
});
|
||||
} else {
|
||||
syncPromise(_.first(data.files), 0)
|
||||
.then(function () {
|
||||
if (data.hasOwnProperty('action') && _.isFunction(_self[data.action])) {
|
||||
_self[data.action](data, function (err, obj) {
|
||||
|
||||
if (err) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: stringify(err, null, 2),
|
||||
data: null
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: stringify(err, null, 2),
|
||||
data: null
|
||||
err: null,
|
||||
data: stringify(obj, null, 2)
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
} else if (!data.hasOwnProperty('action')) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: null,
|
||||
data: stringify(obj, null, 2)
|
||||
data: stringify(true, null, 2)
|
||||
})
|
||||
});
|
||||
});
|
||||
} else if (!data.hasOwnProperty('action')) {
|
||||
} else {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: stringify('Unknow action', null, 2),
|
||||
data: null
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: null,
|
||||
data: stringify(true, null, 2)
|
||||
})
|
||||
});
|
||||
} else {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: stringify('Unknow action', null, 2),
|
||||
err: err,
|
||||
data: null
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (err) {
|
||||
fn({
|
||||
appId: strapi.config.studio.appId,
|
||||
token: strapi.token,
|
||||
encrypted: strapi.rsa.encrypt({
|
||||
err: err,
|
||||
data: null
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
} else if (!data.hasOwnProperty('action')) {
|
||||
fn(strapi.rsa.encrypt(stringify('`action` attribute is missing', null, 2)), strapi.rsa.encryptPrivate(null));
|
||||
} else if (_.isFunction(_self[data.action])) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user