fix: null-guard storage targets and page tags to prevent crashes

pull/8005/head
derekderie 3 weeks ago
parent 6f042e97cc
commit e260896bae

@ -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({

@ -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,

Loading…
Cancel
Save