From 61a2db49dfcb22481c77d819f57bee8909ea68a5 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Fri, 23 Dec 2022 13:38:29 +0100 Subject: [PATCH] server: always use user id for calcDriveUsageOf --- packages/backend/src/server/api/endpoints/drive.ts | 1 - packages/backend/src/server/api/endpoints/users/stats.ts | 2 +- packages/backend/src/services/drive/add-file.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts index 5af27c37f..f8e39fb57 100644 --- a/packages/backend/src/server/api/endpoints/drive.ts +++ b/packages/backend/src/server/api/endpoints/drive.ts @@ -35,7 +35,6 @@ export const paramDef = { export default define(meta, paramDef, async (ps, user) => { const instance = await fetchMeta(true); - // Calculate drive usage const usage = await DriveFiles.calcDriveUsageOf(user.id); return { diff --git a/packages/backend/src/server/api/endpoints/users/stats.ts b/packages/backend/src/server/api/endpoints/users/stats.ts index 55d4f4314..f17ff8b31 100644 --- a/packages/backend/src/server/api/endpoints/users/stats.ts +++ b/packages/backend/src/server/api/endpoints/users/stats.ts @@ -177,7 +177,7 @@ export default define(meta, paramDef, async (ps, me) => { driveFilesCount: DriveFiles.createQueryBuilder('file') .where('file.userId = :userId', { userId: user.id }) .getCount(), - driveUsage: DriveFiles.calcDriveUsageOf(user), + driveUsage: DriveFiles.calcDriveUsageOf(user.id), }); result.followingCount = result.localFollowingCount + result.remoteFollowingCount; diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 20ba24609..18bff576a 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -372,7 +372,7 @@ export async function addFile({ //#region Check drive usage if (user && !isLink) { - const usage = await DriveFiles.calcDriveUsageOf(user); + const usage = await DriveFiles.calcDriveUsageOf(user.id); const instance = await fetchMeta(); const driveCapacity = 1024 * 1024 * (Users.isLocalUser(user) ? instance.localDriveCapacityMb : instance.remoteDriveCapacityMb);