fix(opencode): scan sqlite database without legacy session dir#67
fix(opencode): scan sqlite database without legacy session dir#67mirsella wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the session event collection in src/providers/provider.zig to ensure that extra session files are still scanned even if the main sessions directory is missing or cannot be opened. It also improves error logging when session IDs fail to build or are empty, and adds a unit test to verify this behavior. Feedback on the changes highlights a potential memory leak where a duplicated path string is not freed if appending to relative_paths fails with an out-of-memory error.
| const copy = try shared_allocator.dupe(u8, relative_path); | ||
| try relative_paths.append(shared_allocator, copy); |
There was a problem hiding this comment.
If relative_paths.append fails with error.OutOfMemory, the newly allocated copy will be leaked. Adding an errdefer right after the allocation ensures that copy is freed if the append operation fails.
const copy = try shared_allocator.dupe(u8, relative_path);
errdefer shared_allocator.free(copy);
try relative_paths.append(shared_allocator, copy);
There was a problem hiding this comment.
Fixed in 7143445 by freeing duplicated relative paths if append fails, and applying the same guard to configured extra session file paths.
Summary
Tests