Skip to content

Commit 34b7913

Browse files
cursoragent0xJacky
andcommitted
Fix: Correctly handle file size decrease for incremental indexing
Co-authored-by: jacky-943572677 <[email protected]>
1 parent 8e9fa7d commit 34b7913

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/cron/incremental_indexing.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ func needsIncrementalIndexing(log *nginx_log.NginxLogWithIndex, persistence logI
129129
// Fallback: use aggregated data cautiously by clamping the stored size so grouped entries
130130
// do not trigger false positives when rotation files are aggregated together.
131131
lastModified := time.Unix(log.LastModified, 0)
132-
lastSize := log.LastSize
132+
rawLastSize := log.LastSize
133+
lastSize := rawLastSize
133134
if lastSize == 0 || lastSize > fileSize {
134135
lastSize = fileSize
135136
}
@@ -145,9 +146,9 @@ func needsIncrementalIndexing(log *nginx_log.NginxLogWithIndex, persistence logI
145146
return true
146147
}
147148

148-
if fileSize < lastSize {
149+
if rawLastSize > 0 && fileSize < rawLastSize {
149150
logger.Debugf("File %s needs full re-indexing (fallback path) due to size decrease: old_size=%d, new_size=%d",
150-
log.Path, lastSize, fileSize)
151+
log.Path, rawLastSize, fileSize)
151152
return true
152153
}
153154

0 commit comments

Comments
 (0)