mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-22 21:51:51 +00:00
open seeded file in read-only mode
This commit is contained in:
1 parent
5925c58b6a
commit
952f5aad9e
2 files changed
+13
-10
No files matched your search
@@ -207,9 +207,14 @@ namespace torrents
|
||||
{
|
||||
if (!f.is_open ())
|
||||
{
|
||||
auto mode = std::ios::binary | std::ios::in;
|
||||
auto filePath = fullFilePath;
|
||||
if (isPart) filePath += ".part";
|
||||
f.open (filePath, std::ios::binary | std::ios::in | std::ios::out);
|
||||
if (isPart)
|
||||
{
|
||||
filePath += ".part";
|
||||
mode |= std::ios::out;
|
||||
}
|
||||
f.open (filePath, mode);
|
||||
}
|
||||
auto ts = i2p::util::GetMonotonicSeconds ();
|
||||
if (ts > lastFlushTime + TORRENT_FILE_FLUSH_INTERVAL)
|
||||
|
||||
@@ -806,7 +806,6 @@ namespace torrents
|
||||
{
|
||||
auto ts = i2p::util::GetMonotonicSeconds ();
|
||||
for (auto it: m_Torrents)
|
||||
{
|
||||
if (ts > it.second->GetNextUpdateStatusTime ())
|
||||
{
|
||||
if (!it.second->IsStopped () && (it.second->IsActive () || !it.second->IsComplete ()))
|
||||
@@ -819,15 +818,14 @@ namespace torrents
|
||||
else
|
||||
UpdatePeersPerPiece (it.second);
|
||||
}
|
||||
boost::asio::post (GetDiskIOService (), [torrent = it.second, ts]()
|
||||
{
|
||||
for (auto it: torrent->GetFiles ())
|
||||
if (ts > it->lastAccessTime + TORRENT_FILE_INACTIVITY_TIMEOUT)
|
||||
it->Close ();
|
||||
});
|
||||
it.second->SetNextUpdateStatusTime (ts + TORRENTS_STATUS_UPDATE_INTERVAL + GetLocalDestination ()->GetRng ()() % TORRENTS_STATUS_UPDATE_INTERVAL_VARIANCE);
|
||||
}
|
||||
boost::asio::post (GetDiskIOService (), [torrent = it.second, ts]()
|
||||
{
|
||||
for (auto it: torrent->GetFiles ())
|
||||
if (ts > it->lastAccessTime + TORRENT_FILE_INACTIVITY_TIMEOUT)
|
||||
it->Close ();
|
||||
});
|
||||
}
|
||||
ScheduleStatusUpdate ();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user