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 <wmantly@gmail.com>
This commit is contained in:
2026-07-20 15:10:58 -04:00
parent a66982a00d
commit 8abc2a65e1
+7 -7
View File
@@ -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;