Added hash comparison to duplicate avoidance.

This commit is contained in:
2024-09-11 05:16:58 +02:00
parent 7c6c99c9d1
commit 45123bc630
7 changed files with 305 additions and 35 deletions

View File

@@ -4,7 +4,7 @@ const config = require('config');
const yaml = require('js-yaml');
const interpolate = require('../interpolate');
const textToStream = require('./textToStream');
// const textToStream = require('./textToStream');
const save = require('./save');
async function writeToIndex(posts, profilePaths, user, args) {
@@ -22,6 +22,7 @@ async function writeToIndex(posts, profilePaths, user, args) {
indexed: now,
score: post.score,
title: post.title,
hash: post.hash,
};
if (post.previewFallback) {
@@ -43,7 +44,8 @@ async function writeToIndex(posts, profilePaths, user, args) {
return false;
}
return save(filepath, textToStream(yaml.safeDump(data)));
// return save(filepath, textToStream(yaml.safeDump(data)));
return save(filepath, Buffer.from(yaml.safeDump(data), 'utf8'));
}
module.exports = writeToIndex;