Add folder scan & case insensitivity on ready check.

This commit is contained in:
Patrick Fic
2025-04-01 15:29:39 -07:00
parent 6b82d443eb
commit 50cc7691fa
5 changed files with 252 additions and 120 deletions

View File

@@ -1,12 +1,12 @@
import chokidar, { FSWatcher } from "chokidar";
import { BrowserWindow, Notification } from "electron";
import log from "electron-log/main";
import fs from "fs";
import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck";
import ipcTypes from "../../util/ipcTypes.json";
import ImportJob from "../decoder/decoder";
import store from "../store/store";
let watcher: FSWatcher | null;
async function StartWatcher(): Promise<boolean> {
@@ -136,10 +136,31 @@ async function HandleNewFile(path): Promise<void> {
await ImportJob(path);
}
function GetAllEnvFiles(): string[] {
const directories = store.get("settings.filepaths") as string[];
const files: string[] = [];
directories.forEach((directory) => {
try {
const envFiles = fs
.readdirSync(directory)
.filter((file: string) => file.toLowerCase().endsWith(".env"));
envFiles.forEach((file) => {
const fullPath = path.join(directory, file);
files.push(fullPath);
});
} catch (error) {
log.error(`Failed to read directory ${directory}:`, error);
throw error;
}
});
return files;
}
export {
addWatcherPath,
GetAllEnvFiles,
removeWatcherPath,
StartWatcher,
StopWatcher,
watcher,
removeWatcherPath,
addWatcherPath,
};