diff --git a/bin/createTorrent.js b/bin/createTorrent.js index 31ef141..b547cc1 100644 --- a/bin/createTorrent.js +++ b/bin/createTorrent.js @@ -42,21 +42,25 @@ async function writeTorrentFile(fileName, torrentBuffer) { }); } +const sanitizedAnnounceUURL = CAN_TRACKER_ANNOUNCE_URL.endsWith('/') ? + CAN_TRACKER_ANNOUNCE_URL.slice(0, CAN_TRACKER_ANNOUNCE_URL.length - 1) : + CAN_TRACKER_ANNOUNCE_URL; console.info("Creating torrent..."); createTorrent(argv._, { private: true, announceList: [ - [CAN_TRACKER_ANNOUNCE_URL], + [sanitizedAnnounceUURL], ], urlList: [CAN_TRACKER_WEB_SEED_URL], }, (err, torrentBuffer) => { if (err) throw err; const parsedTorrent = parseTorrent(torrentBuffer); + const torrentFileName = `can_tracker_${parsedTorrent.info.name}.torrent`; return Promise.all([ addTorrentToDatabase(parsedTorrent), - writeTorrentFile(`can_tracker_${parsedTorrent.info.name}.torrent`, torrentBuffer) + writeTorrentFile(torrentFileName, torrentBuffer) ]).then(() => { }) diff --git a/package-lock.json b/package-lock.json index 596e42e..fa8e201 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "can-tracker", - "version": "0.0.4", + "version": "0.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/tracker.js b/tracker.js index de784bb..e79a797 100644 --- a/tracker.js +++ b/tracker.js @@ -7,7 +7,6 @@ const { function filterTorrents(infoHash, params, cb) { - console.log('infoHash:', infoHash); return checkTorrentIsTracked(infoHash).then(isTracked => { if (isTracked) { cb(null); diff --git a/utils.js b/utils.js index 77fe544..529c54a 100644 --- a/utils.js +++ b/utils.js @@ -9,9 +9,7 @@ export function checkEnvironmentVariables() { 'CAN_TRACKER_WEB_SEED_URL' ]); } catch (err) { - console.error('You need to set the following environment variables for CanTracker to work'); - console.error('CAN_TRACKER_ANNOUNCE_URL', 'CAN_TRACKER_PATH', 'CAN_TRACKER_PORT'); - console.log(process.env); + console.error(err.message); process.exit(1); } } \ No newline at end of file