feat(vote): rating update on torrent request

This commit is contained in:
Alexey Kasyanchuk
2018-06-16 15:29:41 +03:00
parent a9c27083da
commit 51caccbce4
3 changed files with 63 additions and 3 deletions

View File

@ -528,10 +528,19 @@ const insertTorrentToDB = (torrent, silent) => {
})
}
const removeTorrentFromDB = (torrent) => {
const removeTorrentFromDB = async (torrent) => {
const {hash} = torrent
mysqlSingle.query('DELETE FROM torrents WHERE hash = ?', hash)
mysqlSingle.query('DELETE FROM files WHERE hash = ?', hash)
await mysqlSingle.query('DELETE FROM torrents WHERE hash = ?', hash)
await mysqlSingle.query('DELETE FROM files WHERE hash = ?', hash)
}
const updateTorrentToDB = async (torrent) => {
if(typeof torrent !== 'object')
return
delete torrent.id
await mysqlSingle.updateValues('torrents', torrent, {hash: torrent.hash})
}
const updateTorrent = (metadata, infohash, rinfo) => {
@ -718,6 +727,7 @@ API({
crypto,
insertTorrentToDB,
removeTorrentFromDB,
updateTorrentToDB,
checkTorrent,
p2pStore,
feed