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

View File

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