fix: don't blow up if a collection's root goes missing

This commit is contained in:
Andy Burke 2025-06-30 22:26:25 -07:00
parent 73d4f636cc
commit 0d0f399cc2
2 changed files with 9 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@andyburke/fsdb",
"version": "0.6.0",
"version": "0.6.1",
"license": "MIT",
"exports": {
".": "./fsdb.ts",

View file

@ -224,6 +224,14 @@ export class FSDB_COLLECTION<T extends Record<string, any>> {
let counter = 0;
// TODO: better way to get a pattern to match files in this collection?
const root_stat = await Deno.lstat(this.config.root);
if (!root_stat.isDirectory) {
console.warn(`missing root directory for fsdb collection:`);
console.dir(this.config);
return results;
}
for await (
const entry of fs.walk(this.config.root, {
includeDirs: false,