diff --git a/src/gridcoin/upgrade.cpp b/src/gridcoin/upgrade.cpp index 94b7b58561..09b8d48055 100644 --- a/src/gridcoin/upgrade.cpp +++ b/src/gridcoin/upgrade.cpp @@ -381,6 +381,8 @@ void Upgrade::DownloadSnapshot() error("%s: Exception occurred while attempting to download snapshot (%s)", __func__, e.what()); DownloadStatus.SetSnapshotDownloadFailed(true); + + return; } LogPrint(BCLog::LogFlags::VERBOSE, "INFO: %s: Snapshot download complete.", __func__); @@ -404,6 +406,10 @@ void Upgrade::VerifySHA256SUM() { error("%s: Exception occurred while attempting to retrieve snapshot SHA256SUM (%s)", __func__, e.what()); + + DownloadStatus.SetSHA256SUMFailed(true); + + return; } if (ServerSHA256SUM.empty()) @@ -459,6 +465,7 @@ void Upgrade::VerifySHA256SUM() { LogPrint(BCLog::LogFlags::VERBOSE, "INFO %s: SHA256SUM verification successful.", __func__); + DownloadStatus.SetSHA256SUMProgress(100); DownloadStatus.SetSHA256SUMComplete(true); return; @@ -478,11 +485,20 @@ void Upgrade::CleanupBlockchainData() { fs::path CleanupPath = GetDataDir(); + if (fs::is_symlink(CleanupPath)) + { + LogPrintf("INFO: %s: Data directory is a symlink. True path is %s.", + __func__, fs::read_symlink(CleanupPath).string()); + + CleanupPath = fs::read_symlink(CleanupPath); + } + unsigned int total_items = 0; unsigned int items = 0; // We must delete previous blockchain data // txleveldb + // accrual // blk*.dat fs::directory_iterator IterEnd; @@ -545,6 +561,8 @@ void Upgrade::CleanupBlockchainData() if (!total_items) { + // Nothing to clean up! + DownloadStatus.SetCleanupBlockchainDataComplete(true); return; @@ -652,20 +670,9 @@ void Upgrade::ExtractSnapshot() { try { - // The reason for this ifdef mess is libzip and win32 (at least with libzip 1.32) don't play well together. - // I would prefer to use the CAutoFile structure, which auto-closes files when they fall out of scope and - // deals with unicode filenames properly. However on Windows, zip_open_from_source is not working properly. - // - // For right now, for Win32, we degrade to using the zip_open directly from the filename. Unfortunately this - // means that paths with special Unicode characters may not work properly, because zip_open expects a const char*. - // - // TODO: Research whether this bug has been resolved in the latest version of libzip, and then solve the cmake - // build issues with that for the depends build system. - zip_error_t* err = new zip_error_t; struct zip* ZipArchive; -#ifdef WIN32 std::string archive_file_string = (GetDataDir() / "snapshot.zip").string(); const char* archive_file = archive_file_string.c_str(); @@ -673,16 +680,6 @@ void Upgrade::ExtractSnapshot() ZipArchive = zip_open(archive_file, 0, &ze); zip_error_init_with_code(err, ze); -#else - fs::path archive_path = GetDataDir() / "snapshot.zip"; - - CAutoFile archive_file(fsbridge::fopen(archive_path, "rb"), SER_DISK, CLIENT_VERSION); - - zip_error_init(err); - - zip_source_t* zip_source = zip_source_filep_create(archive_file.Get(), 0, -1, err); - ZipArchive = zip_open_from_source(zip_source, 0, err); -#endif if (ZipArchive == nullptr) { @@ -765,6 +762,7 @@ void Upgrade::ExtractSnapshot() while ((uint64_t) sum < ZipStat.size) { int64_t len = 0; + // Note that using a buffer larger than this risks crashes on macOS. char Buf[256*1024]; boost::this_thread::interruption_point();