diff --git a/bindings/torrent/src/client_session.cc b/bindings/torrent/src/client_session.cc index 1340933..49b94f8 100644 --- a/bindings/torrent/src/client_session.cc +++ b/bindings/torrent/src/client_session.cc @@ -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(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); diff --git a/bindings/torrent/src/client_session.h b/bindings/torrent/src/client_session.h index 3968f04..9a0e7ae 100644 --- a/bindings/torrent/src/client_session.h +++ b/bindings/torrent/src/client_session.h @@ -49,7 +49,6 @@ class Client : public Napi::ObjectWrap { 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); diff --git a/src/main/services/torrent/index.js b/src/main/services/torrent/index.js index 8546bf4..8fa7666 100644 --- a/src/main/services/torrent/index.js +++ b/src/main/services/torrent/index.js @@ -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) } }