WIP indexing non-existing docs
This commit is contained in:
@@ -199,12 +199,15 @@ export class CacheManager {
|
|||||||
// Look for links that lead to non-existing files,
|
// Look for links that lead to non-existing files,
|
||||||
// and add them to the index.
|
// and add them to the index.
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
// const nonExisting = getNonExistingNotes(this.plugin.app, file, metadata)
|
const nonExisting = getNonExistingNotes(this.plugin.app, file, metadata)
|
||||||
// for (const name of nonExisting.filter(
|
for (const name of nonExisting.filter(o => !this.documents.has(o))) {
|
||||||
// o => !this.getLiveDocument(o)
|
const doc =
|
||||||
// )) {
|
this.plugin.notesIndexer.generateIndexableNonexistingDocument(
|
||||||
// NotesIndex.addNonExistingToIndex(name, file.path)
|
name,
|
||||||
// }
|
file.path
|
||||||
|
)
|
||||||
|
// TODO: index non-existing note
|
||||||
|
}
|
||||||
|
|
||||||
// EXCALIDRAW
|
// EXCALIDRAW
|
||||||
// Remove the json code
|
// Remove the json code
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
if (this.notesIndexer.isFileIndexable(file.path)) {
|
if (this.notesIndexer.isFileIndexable(file.path)) {
|
||||||
logDebug('Updating file', file.path)
|
logDebug('Updating file', file.path)
|
||||||
await this.cacheManager.addToLiveCache(file.path)
|
await this.cacheManager.addToLiveCache(file.path)
|
||||||
this.notesIndexer.markNoteForReindex(file)
|
this.notesIndexer.flagNoteForReindex(file)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,16 +18,15 @@ export class NotesIndexer {
|
|||||||
* Updated notes are not reindexed immediately for performance reasons.
|
* Updated notes are not reindexed immediately for performance reasons.
|
||||||
* They're added to a list, and reindex is done the next time we open Omnisearch.
|
* They're added to a list, and reindex is done the next time we open Omnisearch.
|
||||||
*/
|
*/
|
||||||
public markNoteForReindex(note: TAbstractFile): void {
|
public flagNoteForReindex(note: TAbstractFile): void {
|
||||||
this.notesToReindex.add(note)
|
this.notesToReindex.add(note)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async refreshIndex(): Promise<void> {
|
public async refreshIndex(): Promise<void> {
|
||||||
const paths = [...this.notesToReindex].map(n => n.path)
|
const paths = [...this.notesToReindex].map(n => n.path)
|
||||||
if (paths.length) {
|
if (paths.length) {
|
||||||
const searchEngine = this.plugin.searchEngine
|
this.plugin.searchEngine.removeFromPaths(paths)
|
||||||
searchEngine.removeFromPaths(paths)
|
await this.plugin.searchEngine.addFromPaths(paths)
|
||||||
await searchEngine.addFromPaths(paths)
|
|
||||||
this.notesToReindex.clear()
|
this.notesToReindex.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,11 +72,14 @@ export class NotesIndexer {
|
|||||||
* @param name
|
* @param name
|
||||||
* @param parent The note referencing the
|
* @param parent The note referencing the
|
||||||
*/
|
*/
|
||||||
public addNonExistingToIndex(name: string, parent: string): void {
|
public generateIndexableNonexistingDocument(
|
||||||
|
name: string,
|
||||||
|
parent: string
|
||||||
|
): IndexedDocument {
|
||||||
name = removeAnchors(name)
|
name = removeAnchors(name)
|
||||||
const filename = name + (name.endsWith('.md') ? '' : '.md')
|
const filename = name + (name.endsWith('.md') ? '' : '.md')
|
||||||
|
|
||||||
const note: IndexedDocument = {
|
return {
|
||||||
path: filename,
|
path: filename,
|
||||||
basename: name,
|
basename: name,
|
||||||
mtime: 0,
|
mtime: 0,
|
||||||
@@ -94,7 +96,6 @@ export class NotesIndexer {
|
|||||||
doesNotExist: true,
|
doesNotExist: true,
|
||||||
parent,
|
parent,
|
||||||
}
|
}
|
||||||
// searchEngine.addDocuments([note])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFilePlaintext(path: string): boolean {
|
public isFilePlaintext(path: string): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user