diff --git a/src/core/dht_manager.cc b/src/core/dht_manager.cc index 3f683363..611ec72c 100644 --- a/src/core/dht_manager.cc +++ b/src/core/dht_manager.cc @@ -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()); } diff --git a/src/ui/root.cc b/src/ui/root.cc index 84f942e3..e9ed4437 100644 --- a/src/ui/root.cc +++ b/src/ui/root.cc @@ -467,6 +467,9 @@ Root::save_input_history() { history_file << entry << "|" + category.at((pitr->second + i) % m_input_history_length) + "\n"; } + // The data only reaches the kernel here, so this is where a full disk is seen. + history_file.close(); + if (!history_file.good()) { lt_log_print(torrent::LOG_DEBUG, "input history file corrupted during writing, discarding (path:%s)", history_filename.c_str()); return; @@ -474,8 +477,6 @@ Root::save_input_history() { lt_log_print(torrent::LOG_DEBUG, "input history file written (path:%s)", history_filename.c_str()); } - history_file.close(); - std::rename(history_filename_tmp.c_str(), history_filename.c_str()); }