mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Do not consider rewinded the first time block 0 is written.
This commit is contained in:
@@ -292,6 +292,7 @@ typedef struct aaruformat_context
|
|||||||
bool is_writing; ///< True if context opened/created for writing.
|
bool is_writing; ///< True if context opened/created for writing.
|
||||||
bool rewinded; ///< True if stream has been rewound after open (write path).
|
bool rewinded; ///< True if stream has been rewound after open (write path).
|
||||||
bool writing_long; ///< True if writing long sectors
|
bool writing_long; ///< True if writing long sectors
|
||||||
|
bool block_zero_written; ///< True if block zero has been written (writing path).
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
uint32_t lzma_dict_size; ///< LZMA dictionary size (writing path).
|
uint32_t lzma_dict_size; ///< LZMA dictionary size (writing path).
|
||||||
|
|||||||
58
src/write.c
58
src/write.c
@@ -150,19 +150,24 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
|
|||||||
{
|
{
|
||||||
if(sector_address <= ctx->last_written_block)
|
if(sector_address <= ctx->last_written_block)
|
||||||
{
|
{
|
||||||
TRACE("Rewinded");
|
if(sector_address == 0 && !ctx->block_zero_written)
|
||||||
ctx->rewinded = true;
|
ctx->block_zero_written = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACE("Rewinded");
|
||||||
|
ctx->rewinded = true;
|
||||||
|
|
||||||
// Disable MD5 calculation
|
// Disable MD5 calculation
|
||||||
if(ctx->calculating_md5) ctx->calculating_md5 = false;
|
if(ctx->calculating_md5) ctx->calculating_md5 = false;
|
||||||
// Disable SHA1 calculation
|
// Disable SHA1 calculation
|
||||||
if(ctx->calculating_sha1) ctx->calculating_sha1 = false;
|
if(ctx->calculating_sha1) ctx->calculating_sha1 = false;
|
||||||
// Disable SHA256 calculation
|
// Disable SHA256 calculation
|
||||||
if(ctx->calculating_sha256) ctx->calculating_sha256 = false;
|
if(ctx->calculating_sha256) ctx->calculating_sha256 = false;
|
||||||
// Disable SpamSum calculation
|
// Disable SpamSum calculation
|
||||||
if(ctx->calculating_spamsum) ctx->calculating_spamsum = false;
|
if(ctx->calculating_spamsum) ctx->calculating_spamsum = false;
|
||||||
// Disable BLAKE3 calculation
|
// Disable BLAKE3 calculation
|
||||||
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ctx->last_written_block = sector_address;
|
ctx->last_written_block = sector_address;
|
||||||
@@ -642,19 +647,24 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_long(void *context, uint64_t se
|
|||||||
{
|
{
|
||||||
if(sector_address <= ctx->last_written_block)
|
if(sector_address <= ctx->last_written_block)
|
||||||
{
|
{
|
||||||
TRACE("Rewinded");
|
if(sector_address == 0 && !ctx->block_zero_written)
|
||||||
ctx->rewinded = true;
|
ctx->block_zero_written = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACE("Rewinded");
|
||||||
|
ctx->rewinded = true;
|
||||||
|
|
||||||
// Disable MD5 calculation
|
// Disable MD5 calculation
|
||||||
if(ctx->calculating_md5) ctx->calculating_md5 = false;
|
if(ctx->calculating_md5) ctx->calculating_md5 = false;
|
||||||
// Disable SHA1 calculation
|
// Disable SHA1 calculation
|
||||||
if(ctx->calculating_sha1) ctx->calculating_sha1 = false;
|
if(ctx->calculating_sha1) ctx->calculating_sha1 = false;
|
||||||
// Disable SHA256 calculation
|
// Disable SHA256 calculation
|
||||||
if(ctx->calculating_sha256) ctx->calculating_sha256 = false;
|
if(ctx->calculating_sha256) ctx->calculating_sha256 = false;
|
||||||
// Disable SpamSum calculation
|
// Disable SpamSum calculation
|
||||||
if(ctx->calculating_spamsum) ctx->calculating_spamsum = false;
|
if(ctx->calculating_spamsum) ctx->calculating_spamsum = false;
|
||||||
// Disable BLAKE3 calculation
|
// Disable BLAKE3 calculation
|
||||||
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ctx->last_written_block = sector_address;
|
ctx->last_written_block = sector_address;
|
||||||
|
|||||||
Reference in New Issue
Block a user