mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛 Fixed EACCES error from card assets on boot
refs: https://github.com/TryGhost/Ghost/issues/13739 - This is a short term fix to prevent this new feature causing boot errors - This will allow development to continue uninterrupted this week & also allow us to do a rollout - The proper fix will be to move where these files live, which will be done before we go live
This commit is contained in:
parent
ee1fb0d972
commit
bb47b9e327
1 changed files with 14 additions and 6 deletions
|
@ -2,6 +2,7 @@ const Minifier = require('@tryghost/minifier');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
const logging = require('@tryghost/logging');
|
||||||
|
|
||||||
class CardAssetService {
|
class CardAssetService {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
|
@ -49,7 +50,14 @@ class CardAssetService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async minify(globs) {
|
async minify(globs) {
|
||||||
return await this.minifier.minify(globs);
|
try {
|
||||||
|
return await this.minifier.minify(globs);
|
||||||
|
} catch (err) {
|
||||||
|
// @TODO: Convert this back to a proper error once the underlying bug is fixed
|
||||||
|
if (err.code === 'EACCES') {
|
||||||
|
logging.warn('Ghost was not able to write card asset files due to permissions.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearFiles() {
|
async clearFiles() {
|
||||||
|
@ -59,8 +67,8 @@ class CardAssetService {
|
||||||
try {
|
try {
|
||||||
await fs.unlink(path.join(this.dest, 'cards.min.css'));
|
await fs.unlink(path.join(this.dest, 'cards.min.css'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Don't worry if the file didn't exist
|
// Don't worry if the file didn't exist or we don't have perms here
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code !== 'ENOENT' && error.code !== 'EACCES') {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,8 +76,8 @@ class CardAssetService {
|
||||||
try {
|
try {
|
||||||
await fs.unlink(path.join(this.dest, 'cards.min.js'));
|
await fs.unlink(path.join(this.dest, 'cards.min.js'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Don't worry if the file didn't exist
|
// Don't worry if the file didn't exist or we don't have perms here
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code !== 'ENOENT' && error.code !== 'EACCES') {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +102,7 @@ class CardAssetService {
|
||||||
|
|
||||||
const globs = this.generateGlobs();
|
const globs = this.generateGlobs();
|
||||||
|
|
||||||
this.files = await this.minify(globs);
|
this.files = await this.minify(globs) || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue