Address copilot fixes

- Fix search for encrypted pages
- Fix TTL mismatch when searching for matching passwords
This commit is contained in:
Yigit Colakoglu 2025-10-21 19:57:54 +02:00
parent ecd1d1966a
commit 5afcb8cc97
4 changed files with 10 additions and 13 deletions

View File

@ -67,10 +67,8 @@ Quartz supports the following frontmatter:
- encrypt
- `encrypt`
- `encrypted`
- encryptMessage
- `encrypt_message`
- `encryptMessage`
- `encrypt-message`
- encryptConfig
- Overrides for the [[plugins/Encrypt|encryptConfig]]
- password
- `password`

View File

@ -488,10 +488,10 @@ async function fillDocument(data: ContentIndex) {
const promises: Array<Promise<unknown>> = []
for (const [slug, fileData] of Object.entries(data)) {
if (fileData.encryptionResult) {
const slugId = id
let slugId = id
promises.push(
index.addAsync(id, {
id: id++,
index.addAsync(id++, {
id: id,
slug: slug as FullSlug,
title: fileData.title,
content: "",
@ -511,11 +511,10 @@ async function fillDocument(data: ContentIndex) {
fileData.encryptionConfig!,
password,
)
fileData.decrypted = true
index.updateAsync(slugId, {
id,
index.update(slugId++, {
id: slugId,
slug: slug as FullSlug,
title: fileData.title,
content: decryptedContent,

View File

@ -117,7 +117,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
tags: file.data.frontmatter?.tags ?? [],
content: file.data.text ?? "",
richContent:
!file.data.encryptionResult && opts?.rssFullHtml
opts?.rssFullHtml && !file.data.encryptionResult
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
: undefined,
date: date,

View File

@ -429,7 +429,7 @@ export async function addPasswordToCache(
cache[filePath] = {
password,
ttl: ttl <= 0 ? 0 : now + ttl,
ttl: ttl == 0 ? 0 : now + ttl,
}
savePasswordCache(cache)
@ -449,7 +449,7 @@ export function getRelevantPasswords(filePath: string): string[] {
}
})
if (cache[filePath] && cache[filePath].ttl > now) {
if (cache[filePath] && (cache[filePath].ttl > now || cache[filePath].ttl === 0)) {
// If the exact file path is cached, return its password
return [cache[filePath].password]
}