-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from vktr/more-core-functions
Add rechecking
- Loading branch information
Showing
13 changed files
with
207 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <nlohmann/json.hpp> | ||
|
||
#include "../methods/torrentsrecheck_reqres.hpp" | ||
#include "ltinfohash.hpp" | ||
#include "utils.hpp" | ||
|
||
namespace porla::Methods | ||
{ | ||
NLOHMANN_JSONIFY_ALL_THINGS( | ||
TorrentsRecheckReq, | ||
info_hash) | ||
|
||
static void to_json(json& j, const TorrentsRecheckRes& res) | ||
{ | ||
j = {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "torrentsrecheck.hpp" | ||
|
||
#include <libtorrent/torrent_handle.hpp> | ||
#include <libtorrent/torrent_status.hpp> | ||
|
||
#include "../session.hpp" | ||
|
||
using porla::Methods::TorrentsRecheck; | ||
using porla::Methods::TorrentsRecheckReq; | ||
using porla::Methods::TorrentsRecheckRes; | ||
|
||
TorrentsRecheck::TorrentsRecheck(porla::ISession &session) | ||
: m_session(session) | ||
{ | ||
} | ||
|
||
void TorrentsRecheck::Invoke(const TorrentsRecheckReq &req, WriteCb<TorrentsRecheckRes> cb) | ||
{ | ||
auto const& torrents = m_session.Torrents(); | ||
auto const& handle = torrents.find(req.info_hash); | ||
|
||
if (handle == torrents.end()) | ||
{ | ||
return cb.Error(-1, "Torrent not found"); | ||
} | ||
|
||
m_session.Recheck(req.info_hash); | ||
|
||
return cb.Ok(TorrentsRecheckRes{}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "method.hpp" | ||
#include "torrentsrecheck_reqres.hpp" | ||
|
||
namespace porla | ||
{ | ||
class ISession; | ||
} | ||
|
||
namespace porla::Methods | ||
{ | ||
class TorrentsRecheck : public Method<TorrentsRecheckReq, TorrentsRecheckRes> | ||
{ | ||
public: | ||
explicit TorrentsRecheck(ISession& session); | ||
|
||
protected: | ||
void Invoke(const TorrentsRecheckReq& req, WriteCb<TorrentsRecheckRes> cb) override; | ||
|
||
private: | ||
ISession& m_session; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <string> | ||
|
||
#include <libtorrent/info_hash.hpp> | ||
|
||
namespace porla::Methods | ||
{ | ||
struct TorrentsRecheckReq | ||
{ | ||
libtorrent::info_hash_t info_hash; | ||
}; | ||
|
||
struct TorrentsRecheckRes | ||
{ | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters