Handle unable to copy downloaded file #50

develop
Geoffrey Merck 1 year ago
parent 3c0bf94b58
commit ec9518fc4d

@ -59,10 +59,17 @@ bool CHostsFileDownloader::download(const std::string & hostsFileURL, const std:
if(ok) {
outFileName = std::string(outFileNameBuf);
ok = ok && std::filesystem::copy_file(outFileName, hostFilePath, std::filesystem::copy_options::overwrite_existing);
if(!ok) {
CLog::logError("Failed to copy host file to %s", hostFilePath.c_str());
try
{
std::filesystem::copy_file(outFileName, hostFilePath, std::filesystem::copy_options::overwrite_existing);
}
catch(std::filesystem::filesystem_error& e)
{
ok = false;
CLog::logError("Failed to copy host file to %s: %s", hostFilePath.c_str(), e.what());
}
} else {
CLog::logWarning("Failed to download Host file from %s, using previous file", hostsFileURL.c_str());
}

Loading…
Cancel
Save

Powered by TurnKey Linux.