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

Function renameDirectoryOrFile

lib/models/files.ts:688–709  ·  view source on GitHub ↗
(
  userId: string,
  oldPath: string,
  newPath: string,
  oldName: string,
  newName: string,
)

Source from the content-addressed store, hash-verified

686}
687
688async function renameDirectoryOrFile(
689 userId: string,
690 oldPath: string,
691 newPath: string,
692 oldName: string,
693 newName: string,
694): Promise<boolean> {
695 await ensureUserPathIsValidAndSecurelyAccessible(userId, join(oldPath, oldName));
696 await ensureUserPathIsValidAndSecurelyAccessible(userId, join(newPath, newName));
697
698 const oldRootPath = join(await AppConfig.getFilesRootPath(), userId, oldPath);
699 const newRootPath = join(await AppConfig.getFilesRootPath(), userId, newPath);
700
701 try {
702 await Deno.rename(join(oldRootPath, oldName), join(newRootPath, newName));
703 } catch (error) {
704 console.error(error);
705 return false;
706 }
707
708 return true;
709}
710
711async function deleteDirectoryOrFile(userId: string, path: string, name: string): Promise<boolean> {
712 await ensureUserPathIsValidAndSecurelyAccessible(userId, join(path, name));

Callers 2

renameMethod · 0.85
renameMethod · 0.85

Calls 3

getFilesRootPathMethod · 0.80
renameMethod · 0.45

Tested by

no test coverage detected