Don't attempt to save index when there are no posts or profile details (complained about directory not existing)

This commit is contained in:
ThePendulum 2018-07-02 19:55:21 +02:00
parent 7fd3f1c01b
commit 310931e4f8
2 changed files with 4 additions and 4 deletions

View File

@ -29,6 +29,10 @@ async function writeToIndex(posts, profilePaths, user) {
posts: newAndUpdatedEntries.concat(user.indexed.original),
};
if (!data.profile.image && !data.profile.description && !data.posts.length) {
return;
}
return fs.writeFile(filename, yaml.safeDump(data));
}

View File

@ -1,14 +1,10 @@
'use strict';
const config = require('config');
const Promise = require('bluebird');
const fs = require('fs-extra');
const yaml = require('js-yaml');
const getIndex = require('./getIndex.js');
const getArchivePostIds = require('../archives/getArchivePostIds.js');
const curateUser = require('../curate/user.js');
const interpolate = require('../interpolate.js');
async function getUser(username, reddit) {
try {