From 8abc2a65e1a65ff7c552924fb9b040e3dfd36371 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Mon, 20 Jul 2026 15:10:58 -0400 Subject: [PATCH] Validate torrent after hashString is resolved The static Torrent.create override was validating the input data before calling Transmission, but hashString isn't known until after addUrl. Move validation to the final createData object so search/fill can queue torrents without providing a hash up front. Signed-off-by: William Mantly --- models/sql/torrent.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/models/sql/torrent.js b/models/sql/torrent.js index 3df71ae..1db99d1 100644 --- a/models/sql/torrent.js +++ b/models/sql/torrent.js @@ -61,11 +61,6 @@ module.exports = (sequelize, DataTypes, Model) => { static async create(data, ...args){ try{ - - // let instance = this.build(data); - // console.log('instance', instance) - await this.build(data).validate(); - // console.log('validate', val); data.isPrivate = data.isPrivate === 'true' ? true : false; let options = { @@ -89,7 +84,7 @@ module.exports = (sequelize, DataTypes, Model) => { throw error; } - return await super.create({ + let createData = { magnetLink: data.magnetLink, hashString, isPrivate: data.isPrivate, @@ -98,7 +93,12 @@ module.exports = (sequelize, DataTypes, Model) => { category: this.categoryFromTPB(data.category), status: 0, percentDone: 0, - }, args); + }; + + // Validate only after hashString is populated. + await this.build(createData).validate(); + + return await super.create(createData, args); }catch (error){ console.log('Torrent create error', error); throw error;