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
|
||||||
- `encrypt`
|
- `encrypt`
|
||||||
- `encrypted`
|
- `encrypted`
|
||||||
- encryptMessage
|
- encryptConfig
|
||||||
- `encrypt_message`
|
- Overrides for the [[plugins/Encrypt|encryptConfig]]
|
||||||
- `encryptMessage`
|
|
||||||
- `encrypt-message`
|
|
||||||
- password
|
- password
|
||||||
- `password`
|
- `password`
|
||||||
|
|
||||||
|
|||||||
@ -488,10 +488,10 @@ async function fillDocument(data: ContentIndex) {
|
|||||||
const promises: Array<Promise<unknown>> = []
|
const promises: Array<Promise<unknown>> = []
|
||||||
for (const [slug, fileData] of Object.entries(data)) {
|
for (const [slug, fileData] of Object.entries(data)) {
|
||||||
if (fileData.encryptionResult) {
|
if (fileData.encryptionResult) {
|
||||||
const slugId = id
|
let slugId = id
|
||||||
promises.push(
|
promises.push(
|
||||||
index.addAsync(id, {
|
index.addAsync(id++, {
|
||||||
id: id++,
|
id: id,
|
||||||
slug: slug as FullSlug,
|
slug: slug as FullSlug,
|
||||||
title: fileData.title,
|
title: fileData.title,
|
||||||
content: "",
|
content: "",
|
||||||
@ -511,11 +511,10 @@ async function fillDocument(data: ContentIndex) {
|
|||||||
fileData.encryptionConfig!,
|
fileData.encryptionConfig!,
|
||||||
password,
|
password,
|
||||||
)
|
)
|
||||||
|
|
||||||
fileData.decrypted = true
|
fileData.decrypted = true
|
||||||
|
|
||||||
index.updateAsync(slugId, {
|
index.update(slugId++, {
|
||||||
id,
|
id: slugId,
|
||||||
slug: slug as FullSlug,
|
slug: slug as FullSlug,
|
||||||
title: fileData.title,
|
title: fileData.title,
|
||||||
content: decryptedContent,
|
content: decryptedContent,
|
||||||
|
|||||||
@ -117,7 +117,7 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
|||||||
tags: file.data.frontmatter?.tags ?? [],
|
tags: file.data.frontmatter?.tags ?? [],
|
||||||
content: file.data.text ?? "",
|
content: file.data.text ?? "",
|
||||||
richContent:
|
richContent:
|
||||||
!file.data.encryptionResult && opts?.rssFullHtml
|
opts?.rssFullHtml && !file.data.encryptionResult
|
||||||
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
|
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
|
||||||
: undefined,
|
: undefined,
|
||||||
date: date,
|
date: date,
|
||||||
|
|||||||
@ -429,7 +429,7 @@ export async function addPasswordToCache(
|
|||||||
|
|
||||||
cache[filePath] = {
|
cache[filePath] = {
|
||||||
password,
|
password,
|
||||||
ttl: ttl <= 0 ? 0 : now + ttl,
|
ttl: ttl == 0 ? 0 : now + ttl,
|
||||||
}
|
}
|
||||||
|
|
||||||
savePasswordCache(cache)
|
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
|
// If the exact file path is cached, return its password
|
||||||
return [cache[filePath].password]
|
return [cache[filePath].password]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user