Fix file content change handling and improve log messages
- Delete old file_chunks and chunk_files when file content changes - Add DeleteByFileID method to ChunkFileRepository - Add tests to verify old chunks are properly disassociated - Make log messages more precise throughout scanner and snapshot - Support metadata-only snapshots when no files have changed - Add periodic status output during scan and snapshot operations - Improve scan summary output with clearer information
This commit is contained in:
@@ -114,3 +114,21 @@ func (r *ChunkFileRepository) GetByFileID(ctx context.Context, fileID string) ([
|
||||
|
||||
return chunkFiles, rows.Err()
|
||||
}
|
||||
|
||||
// DeleteByFileID deletes all chunk_files entries for a given file ID
|
||||
func (r *ChunkFileRepository) DeleteByFileID(ctx context.Context, tx *sql.Tx, fileID string) error {
|
||||
query := `DELETE FROM chunk_files WHERE file_id = ?`
|
||||
|
||||
var err error
|
||||
if tx != nil {
|
||||
_, err = tx.ExecContext(ctx, query, fileID)
|
||||
} else {
|
||||
_, err = r.db.ExecWithLog(ctx, query, fileID)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("deleting chunk files: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user