Fix multi-segment recording data loss during recovery#1514
Merged
richiemcilroy merged 2 commits intoCapSoftware:mainfrom Feb 3, 2026
Merged
Fix multi-segment recording data loss during recovery#1514richiemcilroy merged 2 commits intoCapSoftware:mainfrom
richiemcilroy merged 2 commits intoCapSoftware:mainfrom
Conversation
The recovery process sorted segment directories alphabetically, causing segment-10 to come before segment-2. Combined with index assignment from enumeration, this caused middle segments (2-9) to be incorrectly processed and their video data lost. Fixes: - Use natural numeric sort for segment directories - Parse segment index from folder name instead of enumeration - Use actual segment path from metadata in create_project_config Fixes CapSoftware#1509 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
Member
|
Thanks for the awesome PR! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1509 - Multi-segment recordings (from pause/resume) lose middle segments during recovery/remux.
Root Cause: The recovery process sorted segment directories alphabetically, causing
segment-10to come beforesegment-2. Combined with index assignment from enumeration, this caused wrong segments to be processed/deleted.Changes:
create_project_configTest Plan
display.mp4andcamera.mp4after recording stopsBefore fix: Only segments 0, 1, 10, 11 preserved; segments 2-9 lost
After fix: All segments 0-9 preserved correctly
🤖 Generated with Claude Code
Greptile Summary
Fixed multi-segment recording data loss during recovery caused by alphabetical sorting treating
segment-10as coming beforesegment-2. The recovery process now uses natural numeric sorting to order segment directories correctly, and parses the segment index directly from folder names (segment-N) instead of relying on enumeration position. Additionally,create_project_confignow uses the actual segment path from metadata instead of reconstructing it from the loop index.Key changes:
create_project_config(line 913)Confidence Score: 5/5
u32::MAX), and the segment index parsing is straightforward with proper fallback to 0.Important Files Changed
Sequence Diagram
sequenceDiagram participant FS as File System participant RM as RecoveryManager participant Sort as Sorting Logic participant Proc as Processing Loop Note over RM: analyze_incomplete() RM->>FS: read_dir(segments_dir) FS-->>RM: [segment-0, segment-1, ..., segment-10, segment-2] RM->>Sort: sort_by_key(natural numeric) Note over Sort: Parse "segment-N" → u32<br/>segment-10 → 10<br/>segment-2 → 2 Sort-->>RM: [segment-0, segment-1, segment-2, ..., segment-10] loop For each segment_entry RM->>Proc: Parse index from folder name Note over Proc: "segment-2" → index=2<br/>(not enumerate index!) Proc->>RM: RecoverableSegment{index: 2, ...} end Note over RM: build_recovered_meta() RM->>RM: Use seg.index for segment_base path Note over RM: segment_base = "content/segments/segment-{seg.index}" Note over RM: create_project_config() RM->>RM: Use segment.display.path from metadata Note over RM: No longer reconstruct from loop index