Check the flush on the dht cache and history

good() ran before close(), so a failed write replaced the file.
This commit is contained in:
noctuum
2026-09-16 19:27:31 +05:00
committed by Jari Sundell
parent c1ce2febf0
commit 8423803b6e
2 changed files with 6 additions and 4 deletions
+3 -2
View File
@@ -132,11 +132,12 @@ DhtManager::save_dht_cache() {
torrent::Object cache = torrent::Object::create_map();
cache_file << *torrent::runtime::network_manager()->dht_controller()->store_cache(&cache);
// The data only reaches the kernel here, so this is where a full disk is seen.
cache_file.close();
if (!cache_file.good())
return;
cache_file.close();
::rename(filename_tmp.c_str(), filename.c_str());
}