mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Recursively search through folders for indexing
This commit is contained in:
@@ -110,6 +110,21 @@ function filenameToMimeType (filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processDirectory(filesToPush, folder) {
|
||||||
|
const files = fs.readdirSync(folder.path, { withFileTypes: true, recursive: true });
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
console.log(file);
|
||||||
|
if (file.isFile() && validFileTypes.includes(file.name.split('.').pop())) {
|
||||||
|
filesToPush.push(path.join(folder.path, file.name));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
processDirectory(filesToPush, {'path': path.join(folder.path, file.name)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function pushDataToKhoj (regenerate = false) {
|
function pushDataToKhoj (regenerate = false) {
|
||||||
// Don't sync if token or hostURL is not set or if already syncing
|
// Don't sync if token or hostURL is not set or if already syncing
|
||||||
if (store.get('khojToken') === '' || store.get('hostURL') === '' || syncing === true) {
|
if (store.get('khojToken') === '' || store.get('hostURL') === '' || syncing === true) {
|
||||||
@@ -132,12 +147,7 @@ function pushDataToKhoj (regenerate = false) {
|
|||||||
|
|
||||||
// Collect paths of all indexable files in configured folders
|
// Collect paths of all indexable files in configured folders
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
const files = fs.readdirSync(folder.path, { withFileTypes: true });
|
processDirectory(filesToPush, folder);
|
||||||
for (const file of files) {
|
|
||||||
if (file.isFile() && validFileTypes.includes(file.name.split('.').pop())) {
|
|
||||||
filesToPush.push(path.join(folder.path, file.name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastSync = store.get('lastSync') || [];
|
const lastSync = store.get('lastSync') || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user