From d57f5d26a539c60287d103eee288dc1cf880f370 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 15 Jan 2023 15:27:08 +0000 Subject: [PATCH] refactor --- packages/backend/src/core/DownloadService.ts | 2 +- packages/backend/src/server/FileServerService.ts | 3 +-- packages/backend/src/server/MediaProxyServerService.ts | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/core/DownloadService.ts b/packages/backend/src/core/DownloadService.ts index b274807b8b..cf76668329 100644 --- a/packages/backend/src/core/DownloadService.ts +++ b/packages/backend/src/core/DownloadService.ts @@ -79,7 +79,7 @@ export class DownloadService { @bindThis public async pipeRequestToFile(_response: Response, path: string): Promise { const response = _response.clone(); - if (response.body === null) { + if (response.body == null) { throw new StatusError('No body', 400, 'No body'); } diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 0bff20bf7f..04ff7113d8 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -108,8 +108,7 @@ export class FileServerService { if (file.isLink && file.uri) { // 期限切れリモートファイル const [path, cleanup] = await createTemp(); try { - const _response = await this.downloadService.fetchUrl(file.uri);; - const response = _response.clone() as NonNullBodyResponse; + const response = await this.downloadService.fetchUrl(file.uri); const fileSaving = this.downloadService.pipeRequestToFile(response, path); let { mime, ext } = await this.fileInfoService.detectRequestType(response); diff --git a/packages/backend/src/server/MediaProxyServerService.ts b/packages/backend/src/server/MediaProxyServerService.ts index e02b0fc839..c7def0a386 100644 --- a/packages/backend/src/server/MediaProxyServerService.ts +++ b/packages/backend/src/server/MediaProxyServerService.ts @@ -74,8 +74,7 @@ export class MediaProxyServerService { // Create temp file const [path, cleanup] = await createTemp(); try { - const _response = await this.downloadService.fetchUrl(url); - const response = _response.clone() as NonNullBodyResponse; + const response = await this.downloadService.fetchUrl(url); const fileSaving = this.downloadService.pipeRequestToFile(response, path); let { mime, ext } = await this.fileInfoService.detectRequestType(response);