diff --git a/server/services/rTorrent/clientGatewayService.ts b/server/services/rTorrent/clientGatewayService.ts index abd80f45..3130cabc 100644 --- a/server/services/rTorrent/clientGatewayService.ts +++ b/server/services/rTorrent/clientGatewayService.ts @@ -63,7 +63,7 @@ class RTorrentClientGatewayService extends ClientGatewayService { }: Required): Promise { const torrentPaths = await Promise.all( files.map(async (file) => { - return saveBufferToTempFile(Buffer.from(file, 'base64'), 'torrent'); + return saveBufferToTempFile(Buffer.from(file, 'base64'), 'torrent', {mode: 0o664}); }), ); diff --git a/server/util/tempFileUtil.ts b/server/util/tempFileUtil.ts index 79cd22d8..c16e3002 100644 --- a/server/util/tempFileUtil.ts +++ b/server/util/tempFileUtil.ts @@ -1,6 +1,6 @@ import axios, {AxiosError, AxiosResponse} from 'axios'; import crypto from 'crypto'; -import fs from 'fs'; +import fs, {WriteFileOptions} from 'fs'; import {getTempPath} from '../models/TemporaryStorage'; @@ -33,10 +33,14 @@ const delayedDelete = (tempPath: string): void => { * @param {string} extension - file extension of temp file * @return {string} - path of saved temporary file. deleted after 5 minutes. */ -export const saveBufferToTempFile = async (buffer: Buffer, extension?: string): Promise => { +export const saveBufferToTempFile = async ( + buffer: Buffer, + extension?: string, + options?: WriteFileOptions, +): Promise => { const tempPath = getTempFilePath(extension); - fs.writeFileSync(tempPath, buffer); + fs.writeFileSync(tempPath, buffer, options); delayedDelete(tempPath);