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 rewinded; ///< True if stream has been rewound after open (write path).
|
||||
bool writing_long; ///< True if writing long sectors
|
||||
bool block_zero_written; ///< True if block zero has been written (writing path).
|
||||
|
||||
/* Options */
|
||||
uint32_t lzma_dict_size; ///< LZMA dictionary size (writing path).
|
||||
|
||||
10
src/write.c
10
src/write.c
@@ -149,6 +149,10 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
|
||||
if(!ctx->rewinded)
|
||||
{
|
||||
if(sector_address <= ctx->last_written_block)
|
||||
{
|
||||
if(sector_address == 0 && !ctx->block_zero_written)
|
||||
ctx->block_zero_written = true;
|
||||
else
|
||||
{
|
||||
TRACE("Rewinded");
|
||||
ctx->rewinded = true;
|
||||
@@ -164,6 +168,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
|
||||
// Disable BLAKE3 calculation
|
||||
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
ctx->last_written_block = sector_address;
|
||||
}
|
||||
@@ -641,6 +646,10 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_long(void *context, uint64_t se
|
||||
if(!ctx->rewinded)
|
||||
{
|
||||
if(sector_address <= ctx->last_written_block)
|
||||
{
|
||||
if(sector_address == 0 && !ctx->block_zero_written)
|
||||
ctx->block_zero_written = true;
|
||||
else
|
||||
{
|
||||
TRACE("Rewinded");
|
||||
ctx->rewinded = true;
|
||||
@@ -656,6 +665,7 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector_long(void *context, uint64_t se
|
||||
// Disable BLAKE3 calculation
|
||||
if(ctx->calculating_blake3) ctx->calculating_blake3 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
ctx->last_written_block = sector_address;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user