MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / getPathEntries

Function getPathEntries

lib/models/files.ts:650–686  ·  view source on GitHub ↗
(userId: string, path: string)

Source from the content-addressed store, hash-verified

648}
649
650async function getPathEntries(userId: string, path: string): Promise<Deno.DirEntry[]> {
651 await ensureUserPathIsValidAndSecurelyAccessible(userId, path);
652
653 const rootPath = join(await AppConfig.getFilesRootPath(), userId, path);
654
655 // Ensure the user directory exists
656 if (path === '/') {
657 try {
658 await Deno.stat(rootPath);
659 } catch (error) {
660 if ((error as Error).toString().includes('NotFound')) {
661 await Deno.mkdir(join(rootPath, TRASH_PATH), { recursive: true });
662 }
663 }
664 }
665
666 // Ensure the Notes or Photos directories exist, if being requested
667 if (path === '/Notes/' || path === '/Photos/') {
668 try {
669 await Deno.stat(rootPath);
670 } catch (error) {
671 if ((error as Error).toString().includes('NotFound')) {
672 await Deno.mkdir(rootPath, { recursive: true });
673 }
674 }
675 }
676
677 const entries: Deno.DirEntry[] = [];
678
679 for await (const dirEntry of Deno.readDir(rootPath)) {
680 entries.push(dirEntry);
681 }
682
683 entries.sort(sortEntriesByName);
684
685 return entries;
686}
687
688async function renameDirectoryOrFile(
689 userId: string,

Callers 2

listMethod · 0.85
listMethod · 0.85

Tested by

no test coverage detected