mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 10:54:06 -06:00
Address copilot fixes
- Fix search for encrypted pages - Fix TTL mismatch when searching for matching passwords
This commit is contained in:
parent
ecd1d1966a
commit
5afcb8cc97
@ -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`
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user