fix duplicate torrents (again)

This commit is contained in:
2026-02-03 18:47:10 +03:00
parent 82b0c567fe
commit 13b132f5f0
2 changed files with 5 additions and 11 deletions

View File

@@ -31,10 +31,10 @@ func (m *Model) GetTorrentById(torrentId int64) (*Torrent, error) {
return torrent, nil
}
func (m *Model) GetTorrentByGuid(guid string) (*Torrent, error) {
func (m *Model) GetTorrentByGuidAndItemId(guid string, itemId int64) (*Torrent, error) {
torrent := new(Torrent)
row := m.db.QueryRowx("SELECT * FROM torrents WHERE guid = ?", guid)
row := m.db.QueryRowx("SELECT * FROM torrents WHERE guid = ? AND item_id = ?", guid, itemId)
if err := row.StructScan(torrent); err != nil {
return nil, fmt.Errorf("torrent not found: %v", err)
}