From b1814a672c14234a742f7d32d22e7b13fdb4dfff Mon Sep 17 00:00:00 2001 From: Scott Laird Date: Tue, 20 Aug 2024 17:32:48 -0700 Subject: [PATCH 1/2] Ignore files over 1 MB This should fix https://github.com/replicatedhq/hugo-algolia/issues/29, which causes hugo-algolia to crash when indexing sites with large files, such as video content. Signed-off-by: Scott Laird --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index f605348..992879c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -212,8 +212,8 @@ function HugoAlgolia(options) { for (let i = 0; i < files.length; i++) { let stats = fs.lstatSync(files[i]); - // Remove folders, only gather actual files - if (!stats.isDirectory()) { + // Remove folders, and ignore files over 1 MB + if (!stats.isDirectory()) && stats.size < 1000000) { // If this is not a directory/folder, read the file self.readFile(files[i]); } From 80e7bdcfd4c7ecc4aa43626c286fcca67620b274 Mon Sep 17 00:00:00 2001 From: Scott Laird Date: Tue, 20 Aug 2024 17:34:56 -0700 Subject: [PATCH 2/2] fix typo Signed-off-by: Scott Laird --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 992879c..99a0aa0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -213,7 +213,7 @@ function HugoAlgolia(options) { let stats = fs.lstatSync(files[i]); // Remove folders, and ignore files over 1 MB - if (!stats.isDirectory()) && stats.size < 1000000) { + if (!stats.isDirectory() && stats.size < 1000000) { // If this is not a directory/folder, read the file self.readFile(files[i]); }