Overwrite existing PDFs in Obsidian as well, make if-block more legible

This commit is contained in:
sabaimran 2023-07-02 16:17:25 -07:00
parent 4b02a8c788
commit eff1436857

View file

@ -73,8 +73,9 @@ export async function configureKhojBackend(vault: Vault, setting: KhojSetting, n
}
}
// Else if khoj is not configured to index markdown files in configured obsidian vault
else if (data["content-type"]["markdown"]["input-filter"] == null ||
else if (
data["content-type"]["markdown"]["input-files"] != null ||
data["content-type"]["markdown"]["input-filter"] == null ||
data["content-type"]["markdown"]["input-filter"].length != 1 ||
data["content-type"]["markdown"]["input-filter"][0] !== mdInVault) {
// Update markdown config in khoj content-type config
@ -89,12 +90,9 @@ export async function configureKhojBackend(vault: Vault, setting: KhojSetting, n
}
if (khoj_already_configured && !data["content-type"]["pdf"]) {
// Add pdf config to khoj content-type config
// Set pdf config to index pdf files in configured obsidian vault
const hasPdfFiles = app.vault.getFiles().some(file => file.extension === 'pdf');
let pdfs = fs.readdirSync(vaultPath).filter(file => file.endsWith(".pdf"));
if (pdfs.length > 0) {
if (hasPdfFiles) {
data["content-type"]["pdf"] = {
"input-filter": [pdfInVault],
"input-files": null,
@ -107,7 +105,9 @@ export async function configureKhojBackend(vault: Vault, setting: KhojSetting, n
}
// Else if khoj is not configured to index pdf files in configured obsidian vault
else if (khoj_already_configured &&
(data["content-type"]["pdf"]["input-filter"] == null ||
(
data["content-type"]["pdf"]["input-files"] != null ||
data["content-type"]["pdf"]["input-filter"] == null ||
data["content-type"]["pdf"]["input-filter"].length != 1 ||
data["content-type"]["pdf"]["input-filter"][0] !== pdfInVault)) {