Merge pull request #8574 from JosJuice/volumeverifier-assert-small-file

VolumeVerifier: Improve the messages shown for files that are too small
This commit is contained in:
Léo Lam 2020-02-09 15:48:57 +01:00 committed by GitHub
commit fb0f543777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 17 deletions

View File

@ -1238,9 +1238,6 @@ void VolumeVerifier::Finish()
WaitForAsyncOperations();
ASSERT(m_content_index == m_content_offsets.size());
ASSERT(m_block_index == m_blocks.size());
if (m_calculating_any_hash)
{
if (m_hashes_to_calculate.crc32)
@ -1267,25 +1264,32 @@ void VolumeVerifier::Finish()
if (m_read_errors_occurred)
AddProblem(Severity::Medium, Common::GetStringT("Some of the data could not be read."));
bool file_too_small = false;
if (m_content_index != m_content_offsets.size() || m_block_index != m_blocks.size())
file_too_small = true;
if (IsDisc(m_volume.GetVolumeType()) &&
(m_volume.IsSizeAccurate() || m_volume.SupportsIntegrityCheck()))
{
u64 volume_size = m_volume.IsSizeAccurate() ? m_volume.GetSize() : m_biggest_verified_offset;
if (m_biggest_referenced_offset > volume_size)
{
const bool second_layer_missing =
m_biggest_referenced_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
std::string text =
second_layer_missing ?
Common::GetStringT("This disc image is too small and lacks some data. The problem is "
"most likely that this is a dual-layer disc that has been dumped "
"as a single-layer disc.") :
Common::GetStringT("This disc image is too small and lacks some data. If your "
"dumping program saved the disc image as several parts, you need "
"to merge them into one file.");
AddProblem(Severity::High, std::move(text));
return;
}
file_too_small = true;
}
if (file_too_small)
{
const bool second_layer_missing =
m_biggest_referenced_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
std::string text =
second_layer_missing ?
Common::GetStringT("This disc image is too small and lacks some data. The problem is "
"most likely that this is a dual-layer disc that has been dumped "
"as a single-layer disc.") :
Common::GetStringT("This disc image is too small and lacks some data. If your "
"dumping program saved the disc image as several parts, you need "
"to merge them into one file.");
AddProblem(Severity::High, std::move(text));
}
for (auto [partition, blocks] : m_block_errors)