diff --git a/server/models/storage.js b/server/models/storage.js index a982b7ec15..26cfab39b4 100644 --- a/server/models/storage.js +++ b/server/models/storage.js @@ -179,7 +179,7 @@ module.exports = class Storage extends Model { static async pageEvent({ event, page }) { try { - for (let target of this.targets) { + for (let target of (this.targets || [])) { await target.fn[event](page) } } catch (err) { @@ -190,7 +190,7 @@ module.exports = class Storage extends Model { static async assetEvent({ event, asset }) { try { - for (let target of this.targets) { + for (let target of (this.targets || [])) { await target.fn[`asset${_.capitalize(event)}`](asset) } } catch (err) { @@ -201,7 +201,7 @@ module.exports = class Storage extends Model { static async getLocalLocations({ asset }) { const locations = [] - const promises = this.targets.map(async (target) => { + const promises = (this.targets || []).map(async (target) => { try { const path = await target.fn.getLocalLocation(asset) locations.push({ diff --git a/server/modules/storage/disk/common.js b/server/modules/storage/disk/common.js index c1980fd0fe..e62c9dc76d 100644 --- a/server/modules/storage/disk/common.js +++ b/server/modules/storage/disk/common.js @@ -87,7 +87,7 @@ module.exports = { id: currentPage.id, title: _.get(pageData, 'title', currentPage.title), description: _.get(pageData, 'description', currentPage.description) || '', - tags: newTags || currentPage.tags.map(t => t.tag), + tags: newTags || (currentPage.tags || []).map(t => t.tag), isPublished: _.get(pageData, 'isPublished', currentPage.isPublished), isPrivate: false, content: pageData.content,