diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp 2026-09-01 20:37:16.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsRPC.cpp 2026-09-01 19:26:24.000000000 +0000 @@ -55,5 +55,4 @@ boost::json::array GetTrackers (std::shared_ptr torrent) const; boost::json::array GetTrackerStats (std::shared_ptr torrent) const; - boost::json::array GetFiles (std::shared_ptr torrent) const; static std::string_view RecognizeClientByPeerID (const PeerConnection::PeerID& peerID); @@ -246,6 +245,4 @@ else if (field == "trackerStats") t["trackerStats"] = GetTrackerStats (torrent); - else if (field == "files") - t["files"] = GetFiles (torrent); else { @@ -300,4 +297,33 @@ } }, + { "files", [](std::shared_ptr torrent) + { + boost::json::array files; + const auto& torrentFiles = torrent->GetFiles (); + if (torrentFiles.empty ()) + { + boost::json::object file; + file["name"] = torrent->GetFullPath ().string (); + file["length"] = torrent->GetLength (); + file["bytesCompleted"] = torrent->GetLength () - torrent->GetLeft (); + files.push_back (file); + } + else + { + auto filesCompleted = torrent->GetFilesCompleted (); + size_t ind = 0; + for (const auto& [filePath, fileSize]: torrentFiles) + { + boost::json::object file; + file["name"] = filePath.string (); + file["length"] = fileSize; + file["bytesCompleted"] = (ind < filesCompleted.size ()) ? filesCompleted[ind] : 0; + files.push_back (file); + ind++; + } + } + return files; + } + }, { "wanted", [](std::shared_ptr torrent) { @@ -445,34 +471,4 @@ } - boost::json::array JSONRPCHandler::GetFiles (std::shared_ptr torrent) const - { - boost::json::array files; - const auto& torrentFiles = torrent->GetFiles (); - if (torrentFiles.empty ()) - { - boost::json::object file; - file["name"] = torrent->GetName (); - file["length"] = torrent->GetLength (); - file["bytesCompleted"] = torrent->GetLength () - torrent->GetLeft (); - files.push_back (file); - } - else - { - const auto& torrentsDir = m_Tunnel->GetTorrentsDir (); - auto filesCompleted = torrent->GetFilesCompleted (); - size_t ind = 0; - for (const auto& [filePath, fileSize]: torrentFiles) - { - boost::json::object file; - file["name"] = std::filesystem::relative (filePath, torrentsDir).string (); - file["length"] = fileSize; - file["bytesCompleted"] = (ind < filesCompleted.size ()) ? filesCompleted[ind] : 0; - files.push_back (file); - ind++; - } - } - return files; - } - std::string_view JSONRPCHandler::RecognizeClientByPeerID (const PeerConnection::PeerID& peerID) { diff -U2 -r /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsTunnel.h /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsTunnel.h --- /var/lib/copr-rpmbuild/results/i2pd-git/upstream-unpacked/Source0/i2pd-openssl/libi2pd_client/TorrentsTunnel.h 2026-09-01 20:37:16.000000000 +0000 +++ /var/lib/copr-rpmbuild/results/i2pd-git/srpm-unpacked/i2pd-openssl.tar.gz-extract/i2pd-openssl/libi2pd_client/TorrentsTunnel.h 2026-09-01 19:26:24.000000000 +0000 @@ -91,5 +91,4 @@ const std::string& GetPeerID () const { return m_PeerID; } - const std::filesystem::path& GetTorrentsDir () const { return m_TorrentsDir; } std::string GetTrackerAnnounce (size_t id) const { return (id < m_Trackers.size ()) ? std::get<0>(m_Trackers[id]) : ""; } size_t GetNumTrackers () const { return m_Trackers.size (); }