diff options
| author | iamamyth <user@example.com> | 2024-12-27 16:04:11 -0800 |
|---|---|---|
| committer | iamamyth <user@example.com> | 2025-01-14 13:26:39 -0800 |
| commit | 36c5987156a31640c4638f1424b98285f6ea4a47 (patch) | |
| tree | 1e285008924b0f39bb54805d88a4417415bb214b /src/common | |
| parent | 7fb0d2f48daf3de3ce1c0d28c4845a7c3dd97284 (diff) | |
| download | monzero-core-36c5987156a31640c4638f1424b98285f6ea4a47.tar.gz monzero-core-36c5987156a31640c4638f1424b98285f6ea4a47.tar.xz monzero-core-36c5987156a31640c4638f1424b98285f6ea4a47.zip | |
Fix get_database_size on Windows
Replace all calls to epee::file_io::get_file_size with
boost::filesystem::file_size in order to avoid lossy conversions from
paths to strings, which tend to break filename resolution. This commit
fixes a bug on Windows where the get_info RPC call reported a zero
database size because BlockchainLMBD::get_database_size returned zero.
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/download.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/common/download.cpp b/src/common/download.cpp index 01d4a9aab..e377be266 100644 --- a/src/common/download.cpp +++ b/src/common/download.cpp @@ -30,7 +30,6 @@ #include <atomic> #include <boost/filesystem.hpp> #include <boost/thread/thread.hpp> -#include "file_io_utils.h" #include "net/http_client.h" #include "download.h" @@ -73,8 +72,11 @@ namespace tools { boost::unique_lock<boost::mutex> lock(control->mutex); std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary; - uint64_t existing_size = 0; - if (epee::file_io_utils::get_file_size(control->path, existing_size) && existing_size > 0) + boost::system::error_code ec{}; + uint64_t existing_size = static_cast<uint64_t>(boost::filesystem::file_size(control->path, ec)); + if (ec) + existing_size = 0; + if (existing_size > 0) { MINFO("Resuming downloading " << control->uri << " to " << control->path << " from " << existing_size); mode |= std::ios_base::app; |
