MCPcopy Create free account
hub / github.com/agent-tower/core / restore

Method restore

packages/server/src/services/project.service.ts:486–529  ·  view source on GitHub ↗
(id: string, input: RestoreProjectInput = {})

Source from the content-addressed store, hash-verified

484 await prisma.workspace.updateMany({
485 where: { id: { in: activeWorkspaceIds } },
486 data: { status: WorkspaceStatus.ABANDONED },
487 });
488 }
489
490 if (input.deleteRepo) {
491 const uniqueWorktreePaths = Array.from(
492 new Set(
493 allWorkspaces
494 .filter((workspace) => workspace.workspaceKind === WorkspaceKind.WORKTREE)
495 .map((workspace) => workspace.worktreePath)
496 .filter((value): value is string => Boolean(value))
497 )
498 );
499
500 await Promise.all(
501 uniqueWorktreePaths.map((worktreePath) =>
502 fsPromises.rm(worktreePath, { recursive: true, force: true })
503 )
504 );
505 await fsPromises.rm(project.repoPath, { recursive: true, force: true });
506
507 if (allWorkspaces.length > 0) {
508 await prisma.workspace.updateMany({
509 where: { id: { in: allWorkspaces.map((workspace) => workspace.id) } },
510 data: { worktreePath: '', workingDir: '' },
511 });
512 }
513 }
514
515 const archived = await prisma.project.update({
516 where: { id },
517 data: {
518 archivedAt: new Date(),
519 repoDeletedAt: input.deleteRepo ? new Date() : null,
520 },
521 });
522 return this.withGitMetadata(archived);
523 },
524 );
525 }
526
527 async restore(id: string, input: RestoreProjectInput = {}): Promise<RestoreProjectResult<any>> {
528 const project = await prisma.project.findUnique({ where: { id } });
529 if (!project) {
530 throw new NotFoundError('Project', id);
531 }
532

Callers 2

projectRoutesFunction · 0.95

Calls 6

withGitMetadataMethod · 0.95
isValidProjectDirectoryFunction · 0.85
resolveProjectPathFunction · 0.85
trimMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected