From c818176ff1ff08a3de46febbdfb47ba8d96f5e45 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Mon, 24 Jul 2023 12:19:53 -0300 Subject: [PATCH 1/3] Do not auto close read file stream --- apps/meteor/server/ufs/ufs-methods.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/meteor/server/ufs/ufs-methods.ts b/apps/meteor/server/ufs/ufs-methods.ts index 724c9406165d..411bf0f66748 100644 --- a/apps/meteor/server/ufs/ufs-methods.ts +++ b/apps/meteor/server/ufs/ufs-methods.ts @@ -45,7 +45,7 @@ export async function ufsComplete(fileId: string, storeName: string): Promise Date: Wed, 11 Oct 2023 13:23:29 -0300 Subject: [PATCH 2/3] Do not create read stream via fd --- apps/meteor/server/lib/dataExport/uploadZipFile.ts | 6 ++---- apps/meteor/server/ufs/ufs-methods.ts | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/meteor/server/lib/dataExport/uploadZipFile.ts b/apps/meteor/server/lib/dataExport/uploadZipFile.ts index e6a76472db7f..c50984ed26bf 100644 --- a/apps/meteor/server/lib/dataExport/uploadZipFile.ts +++ b/apps/meteor/server/lib/dataExport/uploadZipFile.ts @@ -1,5 +1,5 @@ import { createReadStream } from 'fs'; -import { open, stat } from 'fs/promises'; +import { stat } from 'fs/promises'; import type { IUser } from '@rocket.chat/core-typings'; import { Users } from '@rocket.chat/models'; @@ -28,9 +28,7 @@ export const uploadZipFile = async (filePath: string, userId: IUser['_id'], expo name: newFileName, }; - const { fd } = await open(filePath); - - const stream = createReadStream('', { fd }); // @todo once upgrades to Node.js v16.x, use createReadStream from fs.promises.open + const stream = createReadStream(filePath); // @todo once upgrades to Node.js v16.x, use createReadStream from fs.promises.open const userDataStore = FileUpload.getStore('UserDataFiles'); diff --git a/apps/meteor/server/ufs/ufs-methods.ts b/apps/meteor/server/ufs/ufs-methods.ts index e111eecbceab..05228e059292 100644 --- a/apps/meteor/server/ufs/ufs-methods.ts +++ b/apps/meteor/server/ufs/ufs-methods.ts @@ -45,7 +45,7 @@ export async function ufsComplete(fileId: string, storeName: string): Promise { removeTempFile(); - rs.close(); if (err) { return reject(err); From 1a22b318e61e818ea4f6c527c459ae27ddf00283 Mon Sep 17 00:00:00 2001 From: Matheus Barbosa Silva <36537004+matheusbsilva137@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:33:00 -0300 Subject: [PATCH 3/3] Create changesets --- .changeset/giant-baboons-beam.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/giant-baboons-beam.md diff --git a/.changeset/giant-baboons-beam.md b/.changeset/giant-baboons-beam.md new file mode 100644 index 000000000000..1ba1a8138426 --- /dev/null +++ b/.changeset/giant-baboons-beam.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixed server side error when exporting rooms messages as file