From aeee04415df26108b2c74f679778ee3d8884e9ce Mon Sep 17 00:00:00 2001 From: Etienne <45695613+etiennejouan@users.noreply.github.com> Date: Thu, 22 May 2025 15:25:19 +0200 Subject: [PATCH] add more logs to cleaning command (#12219) --- .../0-54/0-54-clean-not-found-files.command.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/0-54/0-54-clean-not-found-files.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/0-54/0-54-clean-not-found-files.command.ts index 955c39a18..c9a258a08 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/0-54/0-54-clean-not-found-files.command.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/0-54/0-54-clean-not-found-files.command.ts @@ -57,6 +57,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat } private async checkIfFileIsFound(path: string, workspaceId: string) { + this.logger.log(`Checking if file is found ${path}`); if (path.startsWith('https://')) return true; // seed data try { @@ -70,14 +71,18 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat error instanceof FileStorageException && error.code === FileStorageExceptionCode.FILE_NOT_FOUND ) { + this.logger.log(`File not found`); + return false; } } + this.logger.log(`File found`); return true; } private async cleanWorkspaceLogo(workspaceId: string, dryRun: boolean) { + this.logger.log(`Cleaning workspace logo for workspace ${workspaceId}`); const workspace = await this.workspaceRepository.findOneOrFail({ where: { id: workspaceId, @@ -86,7 +91,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat if (!isNonEmptyString(workspace.logo)) return; - this.logger.log('Processing workspace logo for workspace', workspace.id); + this.logger.log(`Processing workspace logo for workspace ${workspace.id}`); const isFileFound = await this.checkIfFileIsFound( workspace.logo, @@ -106,6 +111,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat } private async softDeleteAttachments(workspaceId: string, dryRun: boolean) { + this.logger.log(`Cleaning attachments for workspace ${workspaceId}`); const attachmentRepository = await this.twentyORMGlobalManager.getRepositoryForWorkspace( workspaceId, @@ -124,7 +130,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat const attachmentIdsToSoftDeleteChunk = await Promise.all( attachmentsChunk.map(async (attachment) => { - this.logger.log('Processing attachment', attachment.id); + this.logger.log(`Processing attachment ${attachment.id}`); const isFileFound = await this.checkIfFileIsFound( attachment.fullPath, workspaceId, @@ -153,6 +159,9 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat workspaceId: string, dryRun: boolean, ) { + this.logger.log( + `Cleaning workspace members avatarUrl for workspace ${workspaceId}`, + ); const workspaceMemberRepository = await this.twentyORMGlobalManager.getRepositoryForWorkspace( workspaceId, @@ -167,7 +176,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat const workspaceMemberIdsToUpdate: string[] = []; for (const workspaceMember of workspaceMembers) { - this.logger.log('Processing workspaceMember', workspaceMember.id); + this.logger.log(`Processing workspaceMember ${workspaceMember.id}`); const isFileFound = await this.checkIfFileIsFound( workspaceMember.avatarUrl, @@ -192,6 +201,7 @@ export class CleanNotFoundFilesCommand extends ActiveOrSuspendedWorkspacesMigrat } private async cleanPeopleAvatarUrl(workspaceId: string, dryRun: boolean) { + this.logger.log(`Cleaning people avatarUrl for workspace ${workspaceId}`); const personRepository = await this.twentyORMGlobalManager.getRepositoryForWorkspace( workspaceId,