Fixed remove song bug, making the server crash

This commit is contained in:
Kasper Rynning-Tønnesen
2015-04-17 22:32:11 +02:00
parent e3428ec7b2
commit 73e64de1ff

View File

@@ -370,7 +370,7 @@ function hash_pass(adminpass)
function vote(coll, id, guid, socket) function vote(coll, id, guid, socket)
{ {
db.collection(coll).find({id:id}, function(err, docs){ db.collection(coll).find({id:id}, function(err, docs){
if(!contains(docs[0]["guids"], guid)) if(docs.length > 0 && !contains(docs[0]["guids"], guid))
{ {
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:get_time()}}, function(err, docs) db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:get_time()}}, function(err, docs)
{ {