fix: use correct prefix for counting

This commit is contained in:
zhom
2026-02-16 14:46:17 +04:00
parent 59706e62c1
commit d6b05e04a6
+5 -4
View File
@@ -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<number> {
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);