Moved url cache loading logic behind the flag

refs https://github.com/TryGhost/Toolbox/issues/125

- The url loader is not fully working and is in very experimental mode. The aim is to ship this version to allow other team members to play with the feature in limited use-cases like testing evnironment
This commit is contained in:
Naz 2021-11-12 14:48:17 +04:00 committed by naz
parent 5b2009a268
commit 04c6716171

View File

@ -3,6 +3,7 @@ const _debug = require('@tryghost/debug')._base;
const debug = _debug('ghost:services:url:service');
const _ = require('lodash');
const errors = require('@tryghost/errors');
const labs = require('../../../shared/labs');
const UrlGenerator = require('./UrlGenerator');
const Queue = require('./Queue');
const Urls = require('./Urls');
@ -313,15 +314,15 @@ class UrlService {
}
async persistUrls() {
if (!this.urlCachePath) {
if (!labs.isSet('urlCache') || !this.urlCachePath) {
return null;
}
return fs.writeFileSync(this.urlCachePath, JSON.stringify(this.urls.urls, null, 4));
return fs.writeFile(this.urlCachePath, JSON.stringify(this.urls.urls, null, 4));
}
async fetchUrls() {
if (!this.urlCachePath) {
if (!labs.isSet('urlCache') || !this.urlCachePath) {
return null;
}