From daadad385902a47a8d25eba7732c974fe7abd47e Mon Sep 17 00:00:00 2001
From: timothycarambat <rambat1010@gmail.com>
Date: Wed, 20 Dec 2023 19:41:16 -0800
Subject: [PATCH] hoist var in extensions

---
 collector/processLink/convert/generic.js            | 2 +-
 collector/processSingleFile/convert/asAudio.js      | 2 +-
 collector/processSingleFile/convert/asDocx.js       | 2 +-
 collector/processSingleFile/convert/asMbox.js       | 2 +-
 collector/processSingleFile/convert/asOfficeMime.js | 2 +-
 collector/processSingleFile/convert/asPDF.js        | 5 ++---
 collector/processSingleFile/convert/asTxt.js        | 2 +-
 collector/processSingleFile/index.js                | 3 +--
 8 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/collector/processLink/convert/generic.js b/collector/processLink/convert/generic.js
index 6af41f6cf..f42dcd171 100644
--- a/collector/processLink/convert/generic.js
+++ b/collector/processLink/convert/generic.js
@@ -18,7 +18,7 @@ async function scrapeGenericUrl(link) {
   const url = new URL(link);
   const filename = (url.host + "-" + url.pathname).replace(".", "_");
 
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + slugify(filename) + ".html",
     title: slugify(filename) + ".html",
diff --git a/collector/processSingleFile/convert/asAudio.js b/collector/processSingleFile/convert/asAudio.js
index 97e958df7..a15207fba 100644
--- a/collector/processSingleFile/convert/asAudio.js
+++ b/collector/processSingleFile/convert/asAudio.js
@@ -46,7 +46,7 @@ async function asAudio({ fullFilePath = "", filename = "" }) {
     return { success: false, reason: `No text content found in ${filename}.` };
   }
 
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + fullFilePath,
     title: filename,
diff --git a/collector/processSingleFile/convert/asDocx.js b/collector/processSingleFile/convert/asDocx.js
index 7c3368657..7a64a042d 100644
--- a/collector/processSingleFile/convert/asDocx.js
+++ b/collector/processSingleFile/convert/asDocx.js
@@ -28,7 +28,7 @@ async function asDocX({ fullFilePath = "", filename = "" }) {
   }
 
   const content = pageContent.join("");
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + fullFilePath,
     title: filename,
diff --git a/collector/processSingleFile/convert/asMbox.js b/collector/processSingleFile/convert/asMbox.js
index 58df98cd6..30883f21b 100644
--- a/collector/processSingleFile/convert/asMbox.js
+++ b/collector/processSingleFile/convert/asMbox.js
@@ -35,7 +35,7 @@ async function asMbox({ fullFilePath = "", filename = "" }) {
       `-- Working on message "${mail.subject || "Unknown subject"}" --`
     );
 
-    data = {
+    const data = {
       id: v4(),
       url: "file://" + fullFilePath,
       title: mail?.subject
diff --git a/collector/processSingleFile/convert/asOfficeMime.js b/collector/processSingleFile/convert/asOfficeMime.js
index 49a96b8b1..a6eb0351a 100644
--- a/collector/processSingleFile/convert/asOfficeMime.js
+++ b/collector/processSingleFile/convert/asOfficeMime.js
@@ -23,7 +23,7 @@ async function asOfficeMime({ fullFilePath = "", filename = "" }) {
     return { success: false, reason: `No text content found in ${filename}.` };
   }
 
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + fullFilePath,
     title: filename,
diff --git a/collector/processSingleFile/convert/asPDF.js b/collector/processSingleFile/convert/asPDF.js
index 2509887e8..ca433bf4c 100644
--- a/collector/processSingleFile/convert/asPDF.js
+++ b/collector/processSingleFile/convert/asPDF.js
@@ -18,8 +18,7 @@ async function asPDF({ fullFilePath = "", filename = "" }) {
   const docs = await pdfLoader.load();
   for (const doc of docs) {
     console.log(
-      `-- Parsing content from pg ${
-        doc.metadata?.loc?.pageNumber || "unknown"
+      `-- Parsing content from pg ${doc.metadata?.loc?.pageNumber || "unknown"
       } --`
     );
     if (!doc.pageContent.length) continue;
@@ -33,7 +32,7 @@ async function asPDF({ fullFilePath = "", filename = "" }) {
   }
 
   const content = pageContent.join("");
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + fullFilePath,
     title: docs[0]?.metadata?.pdf?.info?.Title || filename,
diff --git a/collector/processSingleFile/convert/asTxt.js b/collector/processSingleFile/convert/asTxt.js
index 229c175e8..ad35e5476 100644
--- a/collector/processSingleFile/convert/asTxt.js
+++ b/collector/processSingleFile/convert/asTxt.js
@@ -23,7 +23,7 @@ async function asTxt({ fullFilePath = "", filename = "" }) {
   }
 
   console.log(`-- Working ${filename} --`);
-  data = {
+  const data = {
     id: v4(),
     url: "file://" + fullFilePath,
     title: filename,
diff --git a/collector/processSingleFile/index.js b/collector/processSingleFile/index.js
index 3884ca9bd..37c9fd5c5 100644
--- a/collector/processSingleFile/index.js
+++ b/collector/processSingleFile/index.js
@@ -5,8 +5,7 @@ const {
   SUPPORTED_FILETYPE_CONVERTERS,
 } = require("../utils/constants");
 const { trashFile } = require("../utils/files");
-
-RESERVED_FILES = ["__HOTDIR__.md"];
+const RESERVED_FILES = ["__HOTDIR__.md"];
 
 async function processSingleFile(targetFilename) {
   const fullFilePath = path.resolve(WATCH_DIRECTORY, targetFilename);