From 0efeaaec6fd048fdc373aaa6d0c705e6cbbb2016 Mon Sep 17 00:00:00 2001 From: wipedlifepotato <60944239+wipedlifepotato@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:37:52 +0300 Subject: [PATCH 1/2] feat: percentDone torrentRPC --- libi2pd_client/TorrentsRPC.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index b4d822a7..af877772 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -271,6 +271,12 @@ namespace torrents { "pieceCount", [](std::shared_ptr torrent) { return boost::json::value(torrent->GetNumPieces ()); } }, { "pieceSize", [](std::shared_ptr torrent) { return boost::json::value(torrent->GetPieceLength ()); } }, { "totalSize", [](std::shared_ptr torrent) { return boost::json::value(torrent->GetLength ()); } }, + { "percentDone", [](std::shared_ptr torrent) + { + if(!torrent->GetLength()) return boost::json::value ( 100 ); + return boost::json::value( (torrent->GetLength () - torrent->GetLeft ())*100/torrent->GetLength () ); + } + }, { "hashString", [](std::shared_ptr torrent) { std::string hexHash; From f177d2402f471e86caa9b88e4d68de736ed750be Mon Sep 17 00:00:00 2001 From: wipedlifepotato <60944239+wipedlifepotato@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:56:11 +0300 Subject: [PATCH 2/2] feat: percentDone double type --- libi2pd_client/TorrentsRPC.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index af877772..b6a5f864 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -273,8 +273,10 @@ namespace torrents { "totalSize", [](std::shared_ptr torrent) { return boost::json::value(torrent->GetLength ()); } }, { "percentDone", [](std::shared_ptr torrent) { - if(!torrent->GetLength()) return boost::json::value ( 100 ); - return boost::json::value( (torrent->GetLength () - torrent->GetLeft ())*100/torrent->GetLength () ); + if(!torrent->GetLength()) return boost::json::value ( 100.0 ); + double left = torrent->GetLength () - torrent->GetLeft(); + double percent = (left*100)/torrent->GetLength(); + return boost::json::value( percent ); } }, { "hashString", [](std::shared_ptr torrent)