From 7692775942580d3f292779346df1065f7a354415 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Tue, 29 Jul 2025 17:44:47 -0700 Subject: [PATCH] minor change to XLSX parse and upload output folder --- collector/processSingleFile/convert/asXlsx.js | 10 ++-------- collector/utils/files/index.js | 10 ++++------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/collector/processSingleFile/convert/asXlsx.js b/collector/processSingleFile/convert/asXlsx.js index ca9b8eba..3aa8473d 100644 --- a/collector/processSingleFile/convert/asXlsx.js +++ b/collector/processSingleFile/convert/asXlsx.js @@ -6,6 +6,7 @@ const { createdDate, trashFile, writeToServerDocuments, + documentsFolder, } = require("../../utils/files"); const { tokenizeString } = require("../../utils/tokenizer"); const { default: slugify } = require("slugify"); @@ -32,14 +33,7 @@ async function asXlsx({ fullFilePath = "", filename = "" }) { trim: true, }); - const outFolderPath = - process.env.NODE_ENV === "development" - ? path.resolve( - __dirname, - `../../../server/storage/documents/${folderName}` - ) - : path.resolve(process.env.STORAGE_DIR, `documents/${folderName}`); - + const outFolderPath = path.resolve(documentsFolder, folderName); try { const workSheetsFromFile = xlsx.parse(fullFilePath); if (!fs.existsSync(outFolderPath)) diff --git a/collector/utils/files/index.js b/collector/utils/files/index.js index 14b6cf92..29866771 100644 --- a/collector/utils/files/index.js +++ b/collector/utils/files/index.js @@ -101,12 +101,10 @@ function writeToServerDocuments( filename, destinationOverride = null ) { - const destination = destinationOverride - ? path.resolve(destinationOverride) - : path.resolve( - __dirname, - "../../../server/storage/documents/custom-documents" - ); + let destination = null; + if (destinationOverride) destination = path.resolve(destinationOverride); + else destination = path.resolve(documentsFolder, "custom-documents"); + if (!fs.existsSync(destination)) fs.mkdirSync(destination, { recursive: true }); const destinationFilePath = path.resolve(destination, filename) + ".json";