mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-15 16:40:27 +01:00
@@ -546,11 +546,10 @@ exports.announce = function (req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
//write peer data and last_announce_at time
|
||||
//write peer data
|
||||
req.currentPeer.peer_uploaded = query.uploaded;
|
||||
req.currentPeer.peer_downloaded = query.downloaded;
|
||||
req.currentPeer.peer_left = query.peer_left;
|
||||
req.currentPeer.last_announce_at = Date.now();
|
||||
req.currentPeer.save();
|
||||
|
||||
done(null);
|
||||
@@ -564,7 +563,7 @@ exports.announce = function (req, res) {
|
||||
function (done) {
|
||||
if (!req.currentPeer.isNewCreated) {
|
||||
if (req.completeTorrent && req.completeTorrent.complete && event(query.event) !== EVENT_COMPLETED) {
|
||||
req.completeTorrent.total_seed_time += Date.now() - req.currentPeer.last_announce_at;
|
||||
req.completeTorrent.total_seed_time += (Date.now() - req.currentPeer.last_announce_at);
|
||||
req.completeTorrent.save(function () {
|
||||
req.completeTorrent.countHnRWarning(req.passkeyuser);
|
||||
done(null);
|
||||
@@ -576,6 +575,18 @@ exports.announce = function (req, res) {
|
||||
done(null);
|
||||
}
|
||||
},
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
update currentPeer.last_announce_at
|
||||
---------------------------------------------------------------*/
|
||||
function (done) {
|
||||
if (!req.currentPeer.isNewCreated) {
|
||||
req.currentPeer.last_announce_at = Date.now();
|
||||
req.currentPeer.save();
|
||||
}
|
||||
done(null);
|
||||
},
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
onEventCompleted
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
@@ -797,10 +797,7 @@ exports.toggleHnRStatus = function (req, res) {
|
||||
|
||||
//remove the complete data and update user`s warning number when the H&R prop to false
|
||||
if (!torrent.torrent_hnr) {
|
||||
removeTorrentHnRWarning(torrent._id);
|
||||
Complete.remove({
|
||||
torrent: torrent._id
|
||||
}).exec();
|
||||
removeTorrentHnRWarning(torrent._id, true);
|
||||
}
|
||||
|
||||
//add server message
|
||||
@@ -853,7 +850,7 @@ exports.toggleVIPStatus = function (req, res) {
|
||||
* removeTorrentHnRWarning
|
||||
* @param torrent
|
||||
*/
|
||||
function removeTorrentHnRWarning(tid) {
|
||||
function removeTorrentHnRWarning(tid, removeComplete) {
|
||||
Complete.find({
|
||||
torrent: tid
|
||||
})
|
||||
@@ -864,6 +861,9 @@ function removeTorrentHnRWarning(tid) {
|
||||
if (c.hnr_warning) {
|
||||
c.removeHnRWarning(c.user);
|
||||
}
|
||||
if (removeComplete) {
|
||||
c.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1218,10 +1218,7 @@ exports.delete = function (req, res) {
|
||||
}).exec();
|
||||
|
||||
//remove the complete data and update user`s warning number if the torrent has H&R prop
|
||||
removeTorrentHnRWarning(torrent._id);
|
||||
Complete.remove({
|
||||
torrent: torrent._id
|
||||
}).exec();
|
||||
removeTorrentHnRWarning(torrent._id, true);
|
||||
|
||||
torrent.remove(function (err) {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user