blockchain_import: do not error out on truncated files

This will happen often when downloading from a live file
This commit is contained in:
moneromooo-monero 2017-09-01 11:58:51 +01:00
parent d8f402ad8f
commit 8d6967be39
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 13 additions and 3 deletions

View File

@ -326,10 +326,20 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path
}
import_file.read(buffer_block, chunk_size);
if (! import_file) {
if (import_file.eof())
{
std::cout << refresh_string;
MINFO("End of file reached - file was truncated");
quit = 1;
break;
}
else
{
MFATAL("ERROR: unexpected end of file: bytes read before error: "
<< import_file.gcount() << " of chunk_size " << chunk_size);
return 2;
}
}
bytes_read += chunk_size;
MDEBUG("Total bytes read: " << bytes_read);