@@ -117,7 +117,7 @@ function placeSessionEventLogWindow(eventLogPath: string): SessionEventLogWindow
117117 if ( ! newest ) throw unverifiedWindowError ( eventLogPath , 'window file records no generation' ) ;
118118
119119 const activeExists = fileExists ( eventLogPath ) ;
120- const activeStart = placeActiveGeneration ( eventLogPath , newest ) ;
120+ const activeStart = placeActiveGeneration ( readFirstLineDigest ( eventLogPath ) , newest ) ;
121121 const files : EventLogWindowFile [ ] = [ ] ;
122122 const rotatedStart = placeRotatedGeneration ( {
123123 eventLogPath,
@@ -147,8 +147,10 @@ function placeNeverRotatedWindow(eventLogPath: string, rotatedPath: string): Ses
147147 * the sidecar was written, so a first line still matching it means the rename
148148 * has not landed yet and the active file is still that generation.
149149 */
150- function placeActiveGeneration ( eventLogPath : string , newest : EventLogGeneration ) : number {
151- const activeDigest = readFirstLineDigest ( eventLogPath ) ;
150+ function placeActiveGeneration (
151+ activeDigest : string | undefined ,
152+ newest : EventLogGeneration ,
153+ ) : number {
152154 return activeDigest !== undefined && activeDigest === newest . firstLineDigest
153155 ? newest . firstLineIndex
154156 : newest . firstLineIndex + newest . lineCount ;
@@ -214,11 +216,7 @@ export async function rotateSessionEventLogIfNeeded(
214216 throw unverifiedWindowError ( eventLogPath , 'active generation differs from its window record' ) ;
215217 }
216218 const record : EventLogGeneration = {
217- firstLineIndex : activeRecorded
218- ? newest . firstLineIndex
219- : newest
220- ? newest . firstLineIndex + newest . lineCount
221- : 0 ,
219+ firstLineIndex : newest ? placeActiveGeneration ( measured . firstLineDigest , newest ) : 0 ,
222220 lineCount : measured . lineCount ,
223221 firstLineDigest : measured . firstLineDigest ,
224222 } ;
0 commit comments