Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"bittorrent-tracker": "9.19.0",
"body-parser": "^1.19.0",
"chalk": "^4.1.1",
"content-disposition": "^0.5.4",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
Expand Down
10 changes: 7 additions & 3 deletions api/src/controllers/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import crypto from "crypto";
import mongoose from "mongoose";
import { createNGrams, nGrams } from "mongoose-fuzzy-searching/helpers";
import slugify from "slugify";
import contentDisposition from "content-disposition";
import Torrent from "../schema/torrent";
import User from "../schema/user";
import Comment from "../schema/comment";
Expand Down Expand Up @@ -254,13 +255,16 @@ export const downloadTorrent = async (req, res, next) => {
delete parsed["announce-list"];
parsed.info.private = 1;

const fileName = `${parsed.info.name.toString()} - ${
process.env.SQ_SITE_NAME
}.torrent`;

res.setHeader("Content-Type", "application/x-bittorrent");
res.setHeader(
"Content-Disposition",
`attachment;filename=${parsed.info.name.toString()} - ${
process.env.SQ_SITE_NAME
}.torrent`
`attachment;filename=${contentDisposition(fileName)}`
);

res.write(bencode.encode(parsed));
res.end();
} catch (e) {
Expand Down