From d6b05e04a61f53ae16259ab87b0f41ee83aa76ca Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:46:17 +0400 Subject: [PATCH] fix: use correct prefix for counting --- donut-sync/src/sync/sync.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/donut-sync/src/sync/sync.service.ts b/donut-sync/src/sync/sync.service.ts index aec5a0a..f973af9 100644 --- a/donut-sync/src/sync/sync.service.ts +++ b/donut-sync/src/sync/sync.service.ts @@ -559,11 +559,11 @@ export class SyncService implements OnModuleInit { new ListObjectsV2Command({ Bucket: this.bucket, Prefix: profilePrefix, - MaxKeys: ctx.profileLimit + 1, + Delimiter: "/", }), ); - const count = result.Contents?.length || 0; + const count = result.CommonPrefixes?.length || 0; if (count >= ctx.profileLimit) { throw new ForbiddenException( `Profile limit reached (${ctx.profileLimit}). Upgrade your plan for more profiles.`, @@ -572,7 +572,7 @@ export class SyncService implements OnModuleInit { } /** - * Count the number of profile objects for a user. + * Count the number of distinct profile directories for a user. */ private async countProfiles(ctx: UserContext): Promise { const profilePrefix = `${ctx.prefix}profiles/`; @@ -584,11 +584,12 @@ export class SyncService implements OnModuleInit { new ListObjectsV2Command({ Bucket: this.bucket, Prefix: profilePrefix, + Delimiter: "/", MaxKeys: 1000, ContinuationToken: continuationToken, }), ); - count += result.Contents?.length || 0; + count += result.CommonPrefixes?.length || 0; continuationToken = result.NextContinuationToken; } while (continuationToken);