mirror of https://github.com/Kylart/KawAnime.git
Now destroying client when no torrent is left to download or handle
This commit is contained in:
parent
6db5b5e47e
commit
08a6c4ea0d
|
@ -24,8 +24,7 @@ Napi::Object Client::Init(Napi::Env env, Napi::Object exports) {
|
|||
Napi::Function func = DefineClass(
|
||||
env,
|
||||
"Client",
|
||||
{InstanceMethod("destroy", &Client::Destroy),
|
||||
InstanceMethod("addTorrent", &Client::AddTorrent),
|
||||
{InstanceMethod("addTorrent", &Client::AddTorrent),
|
||||
InstanceMethod("getTorrents", &Client::GetTorrents),
|
||||
InstanceMethod("getTorrent", &Client::GetTorrent),
|
||||
InstanceMethod("removeTorrent", &Client::RemoveTorrent),
|
||||
|
@ -45,16 +44,6 @@ Client::Client(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Client>(info)
|
|||
Napi::HandleScope scope(env);
|
||||
}
|
||||
|
||||
Napi::Value Client::Destroy(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
this->session_proxy = this->session.abort();
|
||||
this->session.~session();
|
||||
this->session_proxy.~session_proxy();
|
||||
|
||||
return Napi::Boolean::New(env, true);
|
||||
}
|
||||
|
||||
Napi::Value Client::GetTorrents(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Array result = Napi::Array::New(env);
|
||||
|
|
|
@ -49,7 +49,6 @@ class Client : public Napi::ObjectWrap<Client> {
|
|||
lt::session session;
|
||||
lt::session_proxy session_proxy;
|
||||
|
||||
Napi::Value Destroy(const Napi::CallbackInfo& info);
|
||||
Napi::Value AddTorrent(const Napi::CallbackInfo& info);
|
||||
Napi::Value RemoveTorrent(const Napi::CallbackInfo& info);
|
||||
Napi::Value GetTorrents(const Napi::CallbackInfo &info);
|
||||
|
|
|
@ -30,7 +30,13 @@ function initInfoInterval () {
|
|||
|
||||
sendToWindows(events.info.success, info())
|
||||
|
||||
if (!client.getTorrents().length) stopInfoInterval()
|
||||
if (!client.getTorrents().length) {
|
||||
stopInfoInterval()
|
||||
|
||||
// Destroying client, kinda
|
||||
logger.info('No torrent left in client. Destroying client.')
|
||||
client = null
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue