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: FoundKeyGang/FoundKey#202
Changelog: Fixed
This commit is contained in:
Johann150 2023-01-02 12:23:47 +01:00
parent 7f564431be
commit 2a46719f31
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -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}`;
}