diff --git a/src/clients/Deluge.ts b/src/clients/Deluge.ts index c1a1f3806..a1cb321ba 100644 --- a/src/clients/Deluge.ts +++ b/src/clients/Deluge.ts @@ -193,7 +193,7 @@ export default class Deluge implements TorrentClient { } const params = this.formatData( - `${newTorrent.name}.cross-seed.torrent`, + `${newTorrent.getFileSystemSafeName()}.cross-seed.torrent`, newTorrent.encode().toString("base64"), path ? path : torrentInfo.save_path, !!searchee.infoHash @@ -208,7 +208,9 @@ export default class Deluge implements TorrentClient { ? dataCategory : torrentInfo.label ? duplicateCategories - ? `${torrentInfo.label}.cross-seed` + ? torrentInfo.label.endsWith(".cross-seed") + ? torrentInfo.label + : `${torrentInfo.label}.cross-seed` : torrentInfo.label : this.delugeLabel ); diff --git a/src/clients/QBittorrent.ts b/src/clients/QBittorrent.ts index 95d4ac55d..f7131df25 100644 --- a/src/clients/QBittorrent.ts +++ b/src/clients/QBittorrent.ts @@ -270,7 +270,7 @@ export default class QBittorrent implements TorrentClient { return InjectionResult.ALREADY_EXISTS; } const buf = newTorrent.encode(); - const filename = `${newTorrent.name}.cross-seed.torrent`; + const filename = `${newTorrent.getFileSystemSafeName()}.cross-seed.torrent`; const tempFilepath = join(tmpdir(), filename); await writeFile(tempFilepath, buf, { mode: 0o644 }); const { save_path, isComplete, autoTMM, category } = path diff --git a/src/parseTorrent.ts b/src/parseTorrent.ts index f2ca40246..67302fb04 100644 --- a/src/parseTorrent.ts +++ b/src/parseTorrent.ts @@ -110,6 +110,9 @@ export class Metafile { static decode(buf: Buffer) { return new Metafile(bencode.decode(buf)); } + getFileSystemSafeName(): string { + return this.name.replace("/", ""); + } encode(): Buffer { return bencode.encode(this.raw); diff --git a/src/torrent.ts b/src/torrent.ts index 9905a58b3..8b45e3137 100644 --- a/src/torrent.ts +++ b/src/torrent.ts @@ -111,8 +111,9 @@ export function saveTorrentFile( ): void { const { outputDir } = getRuntimeConfig(); const buf = meta.encode(); - const name = stripExtension(meta.name); - const filename = `[${tag}][${tracker}]${name}.torrent`; + const filename = `[${tag}][${tracker}]${stripExtension( + meta.getFileSystemSafeName() + )}.torrent`; fs.writeFileSync(path.join(outputDir, filename), buf, { mode: 0o644 }); }