mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 18:47:44 +00:00
server: rTorrent: ensure the temporary file is world-readable
This allows rTorrent to read the file when the Flood and rTorrent are running in different users and when the system has a restrictive default umask. Bug: #86
This commit is contained in:
@@ -63,7 +63,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
|
||||
}: Required<AddTorrentByFileOptions>): Promise<void> {
|
||||
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});
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -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<string> => {
|
||||
export const saveBufferToTempFile = async (
|
||||
buffer: Buffer,
|
||||
extension?: string,
|
||||
options?: WriteFileOptions,
|
||||
): Promise<string> => {
|
||||
const tempPath = getTempFilePath(extension);
|
||||
|
||||
fs.writeFileSync(tempPath, buffer);
|
||||
fs.writeFileSync(tempPath, buffer, options);
|
||||
|
||||
delayedDelete(tempPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user