diff --git a/src/format.c b/src/format.c index 5d1e9353..76a30bee 100644 --- a/src/format.c +++ b/src/format.c @@ -1541,10 +1541,17 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) LastRefresh = 0; if (img_report.compression_type != BLED_COMPRESSION_NONE) { + int64_t bled_ret; uprintf("Writing Compressed Image..."); bled_init(_uprintf, update_progress, &FormatStatus); - bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type); + bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type); bled_exit(); + if (bled_ret < 0 && SCODE_CODE(FormatStatus) != ERROR_CANCELLED) { + // Unfortunately, different compression backends return different negative error codes + uprintf("Writing compressed image failed: %" PRIi64, bled_ret); + FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT; + goto out; + } } else { uprintf(hSourceImage?"Writing Image...":"Zeroing drive..."); // Our buffer size must be a multiple of the sector size and *ALIGNED* to the sector size