[PR #1811] [MERGED] fix(rust): correctly count and store multiple input files #2554

Open
opened 2026-01-29 17:22:45 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1811
Author: @cfsmp3
Created: 12/14/2025
Status: Merged
Merged: 12/14/2025
Merged by: @cfsmp3

Base: masterHead: fix/multi-file-processing


📝 Commits (1)

  • 075ae04 fix(rust): correctly count and store multiple input files

📊 Changes

2 files changed (+10 additions, -19 deletions)

View changed files

📝 src/rust/src/common.rs (+7 -2)
📝 src/rust/src/parser.rs (+3 -17)

📄 Description

Summary

  • Fix bug where num_input_files was always set to 1 regardless of how many input files were provided
  • Fix bug where input files were stored at wrong indices (0, 10, 20... instead of 0, 1, 2...)

Root Cause

Two bugs in the Rust argument parsing code prevented multi-file processing from working:

Bug 1: Incorrect iteration in common.rs:216

// BUG: .iter() on Option<Vec<String>> yields 0 or 1 items (the Vec itself), not Vec contents
options.inputfile.iter().filter(|s| !s.is_empty()).count()

// FIX: Iterate over the Vec contents
options.inputfile.as_ref().unwrap().iter().filter(|s| !s.is_empty()).count()

Bug 2: Wrong indexing in parser.rs:append_file_to_queue()

The function used inputfile.len() as the index for new files, but after resize(10, String::new()), the length becomes 10 even with only 1 file. This caused the second file to go to index 10, third to index 20, etc.

Fixed by simply using push() instead of manual index calculation.

Test plan

  • Build ccextractor with fixes
  • Test with multiple input files: ccextractor file1.mpg file2.mpg file3.mpg -o output.srt
  • Verify all files are opened (check for "Opening file:" messages)
  • Verify no crash occurs
  • Run cargo clippy - no warnings on changed files

Fixes #1810

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1811 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/14/2025 **Status:** ✅ Merged **Merged:** 12/14/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/multi-file-processing` --- ### 📝 Commits (1) - [`075ae04`](https://github.com/CCExtractor/ccextractor/commit/075ae04f1d2fc8cc7995ee9312cf0c9d3b43db91) fix(rust): correctly count and store multiple input files ### 📊 Changes **2 files changed** (+10 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `src/rust/src/common.rs` (+7 -2) 📝 `src/rust/src/parser.rs` (+3 -17) </details> ### 📄 Description ## Summary - Fix bug where `num_input_files` was always set to 1 regardless of how many input files were provided - Fix bug where input files were stored at wrong indices (0, 10, 20... instead of 0, 1, 2...) ## Root Cause Two bugs in the Rust argument parsing code prevented multi-file processing from working: ### Bug 1: Incorrect iteration in `common.rs:216` ```rust // BUG: .iter() on Option<Vec<String>> yields 0 or 1 items (the Vec itself), not Vec contents options.inputfile.iter().filter(|s| !s.is_empty()).count() // FIX: Iterate over the Vec contents options.inputfile.as_ref().unwrap().iter().filter(|s| !s.is_empty()).count() ``` ### Bug 2: Wrong indexing in `parser.rs:append_file_to_queue()` The function used `inputfile.len()` as the index for new files, but after `resize(10, String::new())`, the length becomes 10 even with only 1 file. This caused the second file to go to index 10, third to index 20, etc. Fixed by simply using `push()` instead of manual index calculation. ## Test plan - [x] Build ccextractor with fixes - [x] Test with multiple input files: `ccextractor file1.mpg file2.mpg file3.mpg -o output.srt` - [x] Verify all files are opened (check for "Opening file:" messages) - [x] Verify no crash occurs - [x] Run cargo clippy - no warnings on changed files Fixes #1810 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:22:45 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2554