fix(scanner): always add id - replication fix

This commit is contained in:
Alexey Kasyanchuk
2018-03-13 10:45:48 +03:00
parent 268c7d30e4
commit 9c9e64e9a1

View File

@ -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)
{
@ -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);
@ -1125,7 +1128,6 @@ const updateTorrent = (metadata, infohash, rinfo) => {
let filesArray = [];
const filesAdd = (path, size) => filesArray.push({
id: filesId++,
hash,
path,
pathIndex: path,
@ -1151,7 +1153,6 @@ const updateTorrent = (metadata, infohash, rinfo) => {
}
const torrentQ = {
id: torrentsId++,
hash: hash,
name: metadata.info.name,
nameIndex: metadata.info.name,