Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions server/src/indexing/indexing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {fileURLToPath} from "node:url"

import * as path from "node:path"

import * as fs from "node:fs"

import {glob} from "glob"

import {filePathToUri} from "@server/files"
Expand Down Expand Up @@ -40,6 +42,10 @@ export abstract class IndexingRoot {
ignore: ignore,
})
if (files.length === 0) {
if (!this.checkReadAccess(this.root)) {
console.warn(`Can't access ${this.root}`)
}

console.warn(`No file to index in ${this.root}`)
}
for (const filePath of files) {
Expand All @@ -50,5 +56,14 @@ export abstract class IndexingRoot {
}
}

private checkReadAccess(path: string): boolean {
try {
fs.accessSync(path, fs.constants.R_OK)
return true
} catch {
return false
}
}

protected abstract onFile(uri: string): Promise<void>
}