open seeded file in read-only mode

This commit is contained in:
orignal committed 2026-09-14 10:11:42 -04:00
1 parent 5925c58b6a
commit 952f5aad9e
2 files changed
+13 -10

No files matched your search

+7 -2
View File
@@ -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)
+6 -8
View File
@@ -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 ();
}
}