Skip to content

Commit

Permalink
fix(scanner): always add id - replication fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Mar 13, 2018
1 parent a06a81a commit 979ef1b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/background/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ const insertTorrentToDB = (torrent) => {
const { filesList } = torrent
delete torrent.filesList;

torrent.id = torrentsId++;

mysqlSingle.query("SELECT id FROM torrents WHERE hash = ?", torrent.hash, (err, single) => {
if(!single)
{
Expand Down Expand Up @@ -1100,6 +1102,7 @@ const insertTorrentToDB = (torrent) => {
}

filesList.forEach((file) => {
file.id = filesId++;
mysqlSingle.insertValues('files', file, function(err, result) {
if(!result) {
console.log(file);
Expand All @@ -1125,7 +1128,6 @@ const updateTorrent = (metadata, infohash, rinfo) => {
let filesArray = [];

const filesAdd = (path, size) => filesArray.push({
id: filesId++,
hash,
path,
pathIndex: path,
Expand All @@ -1151,7 +1153,6 @@ const updateTorrent = (metadata, infohash, rinfo) => {
}

const torrentQ = {
id: torrentsId++,
hash: hash,
name: metadata.info.name,
nameIndex: metadata.info.name,
Expand Down

0 comments on commit 979ef1b

Please sign in to comment.