From e7dd74a4439e24e0c43ccd09ca4950153d2e19a0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 4 May 2018 16:37:15 +0900 Subject: [PATCH] :v: --- src/services/drive/add-file.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index 50ee117342..1e5b75f125 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -201,7 +201,10 @@ const addFile = async ( // Calculate drive usage const usage = await DriveFile .aggregate([{ - $match: { 'metadata.userId': user._id } + $match: { + 'metadata.userId': user._id, + 'metadata.deletedAt': { $exists: false } + } }, { $project: { length: true @@ -245,7 +248,8 @@ const addFile = async ( DriveFile.update({ _id: oldFile._id }, { $set: { - 'metadata.deletedAt': new Date() + 'metadata.deletedAt': new Date(), + 'metadata.isExpired': true } });