From 0263539202d16eb6a03484e0ead6d184be90de89 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 30 May 2021 13:48:23 +0900 Subject: [PATCH] Fix remote drive expire (#7543) --- src/models/repositories/drive-file.ts | 4 ++++ src/services/drive/add-file.ts | 3 ++- src/services/drive/delete-file.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/models/repositories/drive-file.ts b/src/models/repositories/drive-file.ts index 590079fe4..92bf12a4e 100644 --- a/src/models/repositories/drive-file.ts +++ b/src/models/repositories/drive-file.ts @@ -59,6 +59,7 @@ export class DriveFileRepository extends Repository { const { sum } = await this .createQueryBuilder('file') .where('file.userId = :id', { id: id }) + .andWhere('file.isLink = FALSE') .select('SUM(file.size)', 'sum') .getRawOne(); @@ -69,6 +70,7 @@ export class DriveFileRepository extends Repository { const { sum } = await this .createQueryBuilder('file') .where('file.userHost = :host', { host: toPuny(host) }) + .andWhere('file.isLink = FALSE') .select('SUM(file.size)', 'sum') .getRawOne(); @@ -79,6 +81,7 @@ export class DriveFileRepository extends Repository { const { sum } = await this .createQueryBuilder('file') .where('file.userHost IS NULL') + .andWhere('file.isLink = FALSE') .select('SUM(file.size)', 'sum') .getRawOne(); @@ -89,6 +92,7 @@ export class DriveFileRepository extends Repository { const { sum } = await this .createQueryBuilder('file') .where('file.userHost IS NOT NULL') + .andWhere('file.isLink = FALSE') .select('SUM(file.size)', 'sum') .getRawOne(); diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index ad9f753e7..2356a23cb 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -267,7 +267,8 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string, async function deleteOldFile(user: IRemoteUser) { const q = DriveFiles.createQueryBuilder('file') - .where('file.userId = :userId', { userId: user.id }); + .where('file.userId = :userId', { userId: user.id }) + .andWhere('file.isLink = FALSE'); if (user.avatarId) { q.andWhere('file.id != :avatarId', { avatarId: user.avatarId }); diff --git a/src/services/drive/delete-file.ts b/src/services/drive/delete-file.ts index bb9c0ae2c..2dd244532 100644 --- a/src/services/drive/delete-file.ts +++ b/src/services/drive/delete-file.ts @@ -79,7 +79,7 @@ async function postProcess(file: DriveFile, isExpired = false) { url: file.uri, thumbnailUrl: null, webpublicUrl: null, - size: 0, + storedInternal: false, // ローカルプロキシ用 accessKey: uuid(), thumbnailAccessKey: 'thumbnail-' + uuid(),