mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-22 15:21:45 +00:00
close all active seesions on stop. Check if .part file exists before renaming
This commit is contained in:
1 parent
8edd903a79
commit
d5a6c93d3d
1 file changed
+10
-4
@@ -84,6 +84,7 @@ namespace torrents
|
||||
m_KeepAliveCheckTimer.cancel ();
|
||||
m_ReconnectCheckTimer.cancel ();
|
||||
m_TorrentsStatusUpdateTimer.cancel ();
|
||||
i2p::client::I2PService::ClearHandlers (); // close connections
|
||||
for (auto it: m_Torrents)
|
||||
RequestTorrentTrackers (it.second, eTrackerAnnounceEventStopped);
|
||||
m_Torrents.clear ();
|
||||
@@ -243,11 +244,16 @@ namespace torrents
|
||||
{
|
||||
auto partFilePath = torrent->GetFullPath (); partFilePath += ".part";
|
||||
std::error_code ec;
|
||||
std::filesystem::rename (partFilePath, torrent->GetFullPath (), ec);
|
||||
if (!ec)
|
||||
if (std::filesystem::exists (partFilePath))
|
||||
{
|
||||
std::filesystem::rename (partFilePath, torrent->GetFullPath (), ec);
|
||||
if (!ec)
|
||||
completed = true;
|
||||
else
|
||||
LogPrint (eLogError, "TorrentsTunnel: Can't rename ", partFilePath);
|
||||
}
|
||||
else if (std::filesystem::exists (torrent->GetFullPath ()))
|
||||
completed = true;
|
||||
else
|
||||
LogPrint (eLogError, "TorrentsTunnel: Can't rename ", partFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user