From b5a25968d60629d95dc95c24fe022a5fa3e83c60 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 23 Feb 2003 03:26:37 +0000 Subject: [PATCH] Fixed a rare bug. Put two files in an archive, recompress them (use exerciser dt/at after sev 2 10), flush, then delete the first one and flush. The archive gets trashed, because the record's fileOffset wasn't getting updated properly. --- nufxlib-0/ChangeLog.txt | 4 ++++ nufxlib-0/Deferred.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nufxlib-0/ChangeLog.txt b/nufxlib-0/ChangeLog.txt index c5402f7..761ed1a 100644 --- a/nufxlib-0/ChangeLog.txt +++ b/nufxlib-0/ChangeLog.txt @@ -1,3 +1,7 @@ +2003/02/22 fadden + - Turn off EOL conversion when extracting disk images. + - Added NuTestRecord(). + 2003/02/18 fadden - Added "original pathname" fields to NuFileDetails and NuErrorStatus. - Changed callback setters to return NuCallback instead of NuError. diff --git a/nufxlib-0/Deferred.c b/nufxlib-0/Deferred.c index ed7bb30..4b3865f 100644 --- a/nufxlib-0/Deferred.c +++ b/nufxlib-0/Deferred.c @@ -378,8 +378,8 @@ Nu_CopyArchiveRecord(NuArchive* pArchive, NuRecord* pRecord) BailError(err); offsetAdjust = outputOffset - pRecord->fileOffset; - DBUG(("--- Copying record '%s' (adj=%ld)\n", pRecord->filename, - offsetAdjust)); + DBUG(("--- Copying record '%s' (curOff=%ld adj=%ld)\n", pRecord->filename, + outputOffset, offsetAdjust)); /* seek to the start point in the source file, and copy the whole thing */ err = Nu_FSeek(pArchive->archiveFp, pRecord->fileOffset, SEEK_SET); @@ -399,6 +399,7 @@ Nu_CopyArchiveRecord(NuArchive* pArchive, NuRecord* pRecord) Assert(outputOffset + pRecord->recHeaderLength + pRecord->totalCompLength == (ulong)ftell(pArchive->tmpFp)); + Assert(pRecord->fileOffset == outputOffset); bail: return err; @@ -1211,6 +1212,11 @@ Nu_ConstructArchiveRecord(NuArchive* pArchive, NuRecord* pRecord) err = Nu_FSeek(pArchive->tmpFp, finalOffset, SEEK_SET); BailError(err); + /* update the record's fileOffset to reflect its new position */ + DBUG(("+++ record shifted by %ld bytes\n", + initialOffset - pRecord->fileOffset)); + pRecord->fileOffset = initialOffset; + bail: if (err == kNuErrSkipped) { /*