From 2a46719f312e7ec7f02509383240e40dad18705c Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 2 Jan 2023 12:23:47 +0100 Subject: [PATCH] server: set file permissions after copy This explicitly sets the file permissions to allow everyone to read files since apparently multer sometimes doesn't set the permissions we expect. Ref: https://akkoma.dev/FoundKeyGang/FoundKey/issues/202 Changelog: Fixed --- packages/backend/src/services/drive/internal-storage.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/drive/internal-storage.ts b/packages/backend/src/services/drive/internal-storage.ts index e76749d6c..ee067844f 100644 --- a/packages/backend/src/services/drive/internal-storage.ts +++ b/packages/backend/src/services/drive/internal-storage.ts @@ -18,7 +18,9 @@ export class InternalStorage { public static saveFromPath(key: string, srcPath: string): string { fs.mkdirSync(InternalStorage.path, { recursive: true }); - fs.copyFileSync(srcPath, InternalStorage.resolvePath(key)); + const target = InternalStorage.resolvePath(key); + fs.copyFileSync(srcPath, target); + fs.chmodSync(target, 0o644); return `${config.url}/files/${key}`; }