Skip to content

Commit

Permalink
fix(文章生成): 修复因为缓存导致的删除的文章还会同步的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
furacas committed Jul 24, 2022
1 parent f967330 commit 231f237
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Downloader {
* @return {Promise} queue
*/
async fetchArticles() {
const { client, config, _cachedArticles } = this;
const { client, config } = this;
const articles = await client.getArticles();
if (!Array.isArray(articles.data)) {
throw new Error(
Expand All @@ -95,6 +95,9 @@ class Downloader {
)
.filter(article => (config.onlyPublic ? !!article.public : true))
.map(article => lodash.pick(article, PICK_PROPERTY));

this._cachedArticles = this._cachedArticles.filter(cache => realArticles.findIndex((item)=>item.slug === cache.slug) != -1);

const queue = new Queue({ concurrency: config.concurrency });

let article;
Expand All @@ -105,6 +108,8 @@ class Downloader {
const findIndexFn = function(item) {
return item.slug === article.slug;
};

const { _cachedArticles } = this;

for (let i = 0; i < realArticles.length; i++) {
article = realArticles[i];
Expand Down

0 comments on commit 231f237

Please sign in to comment.