mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
fix: list-directory returns flat array, drop defensive fallback
The list-directory handler returned { path, entries } while the
renderer typed result.data as FileEntry[]; the file-store had to fall
back to raw.entries via Array.isArray. Extract the entries builder into
src/main/files/list-directory.js so it can be unit-tested, return a
plain array, and skip entries that can't be stat'd (broken symlinks,
permission errors) instead of throwing.
Also tighten jest config so dist/*.snap electron-builder artifacts are
not matched as test suites.
This commit is contained in:
@@ -86,8 +86,7 @@ export const useFileStore = create<FileState>()(
|
||||
return;
|
||||
}
|
||||
|
||||
const raw: any = result.data!;
|
||||
const entries: any[] = Array.isArray(raw) ? raw : raw.entries;
|
||||
const entries = result.data ?? [];
|
||||
const children: FileNode[] = entries.map(entryToNode);
|
||||
|
||||
set((s) => {
|
||||
@@ -119,8 +118,7 @@ export const useFileStore = create<FileState>()(
|
||||
|
||||
set((s) => {
|
||||
updateNode(s.tree!, dirPath, (node) => {
|
||||
const raw: any = result.data!;
|
||||
const items: any[] = Array.isArray(raw) ? raw : raw.entries;
|
||||
const items = result.data ?? [];
|
||||
node.children = items.map(entryToNode);
|
||||
node.loaded = true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user