From 9ee9cf8d811f7ef9079980c02270b5a16623d9ef Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Wed, 12 Dec 2018 11:46:35 +0900 Subject: [PATCH] Fix URL after deleting remote file (#3597) * Fix URL after deleting remote file * expired only * delete space --- src/services/drive/delete-file.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/services/drive/delete-file.ts b/src/services/drive/delete-file.ts index 92d0010bc..609c3a86e 100644 --- a/src/services/drive/delete-file.ts +++ b/src/services/drive/delete-file.ts @@ -33,11 +33,24 @@ export default async function(file: IDriveFile, isExpired = false) { files_id: file._id }); - await DriveFile.update({ _id: file._id }, { - $set: { - 'metadata.deletedAt': new Date(), - 'metadata.isExpired': isExpired + const set = { + metadata: { + deletedAt: new Date(), + isExpired: isExpired } + } as any; + + // リモートファイル期限切れ削除後は直リンクにする + if (isExpired && file.metadata && file.metadata._user && file.metadata._user.host != null) { + set.metadata.withoutChunks = true; + set.metadata.isRemote = true; + set.metadata.url = file.metadata.uri; + set.metadata.thumbnailUrl = undefined; + set.metadata.webpublicUrl = undefined; + } + + await DriveFile.update({ _id: file._id }, { + $set: set }); //#region サムネイルもあれば削除