fix: message deletion fails if has files attached on filesystem storage (#29313)

pull/29485/head
Debdut Chakraborty 3 years ago committed by Diego Sampaio
parent ba3f35e75f
commit 82273fac3d
No known key found for this signature in database
GPG Key ID: B71D302EB7F5183C
  1. 5
      .changeset/friendly-spies-retire.md
  2. 15
      apps/meteor/server/ufs/ufs-local.ts

@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---
fix: message deletion fails if has files attached on filesystem storage

@ -69,12 +69,17 @@ export class LocalStore extends Store {
this.delete = async (fileId) => {
const path = await this.getFilePath(fileId);
const statResult = await stat(path);
if (statResult?.isFile()) {
await unlink(path);
await this.removeById(fileId);
try {
if (!(await stat(path)).isFile()) {
return;
}
} catch (_e) {
// FIXME(user) don't ignore, rather this block shouldn't run twice like it does now
return;
}
await unlink(path);
await this.removeById(fileId);
};
this.getReadStream = async (fileId: string, file: IUpload, options?: { start?: number; end?: number }) => {

Loading…
Cancel
Save