[PR #1877] [MERGED] [FIX] Delete empty output files instead of leaving 0-byte files (#1282) #2655

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1877
Author: @cfsmp3
Created: 12/21/2025
Status: Merged
Merged: 1/8/2026
Merged by: @cfsmp3

Base: masterHead: fix/issue-1282-delete-empty-output-files


📝 Commits (1)

  • 800c9a7 fix: Delete empty output files instead of leaving 0-byte files (#1282)

📊 Changes

1 file changed (+12 additions, -0 deletions)

View changed files

📝 src/lib_ccx/output.c (+12 -0)

📄 Description

Summary

  • When using --output-field both, CCExtractor creates separate output files for each field
  • If one field has no captions (e.g., CC3 when only CC1 has data), a 0-byte file was left behind
  • This fix checks file size in dinit_write() before closing - if empty, deletes the file

Approach

This is a simpler approach than PR #1793 (deferred file creation):

  • Files are still created at initialization (no changes to init path)
  • At cleanup, if a file is empty (0 bytes), it's deleted with an informational message
  • Minimal code change (1 file, ~12 lines)

Test Results

$ ccextractor sample.ts --output-field both -o /tmp/test.srt
...
Deleted empty output file: /tmp/test_2.srt

Only the file with actual captions remains.

Fixes #1282

🤖 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/1877 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/21/2025 **Status:** ✅ Merged **Merged:** 1/8/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/issue-1282-delete-empty-output-files` --- ### 📝 Commits (1) - [`800c9a7`](https://github.com/CCExtractor/ccextractor/commit/800c9a7f87c1494db41c9503d0ca7f79dd9ae07f) fix: Delete empty output files instead of leaving 0-byte files (#1282) ### 📊 Changes **1 file changed** (+12 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/output.c` (+12 -0) </details> ### 📄 Description ## Summary - When using `--output-field both`, CCExtractor creates separate output files for each field - If one field has no captions (e.g., CC3 when only CC1 has data), a 0-byte file was left behind - This fix checks file size in `dinit_write()` before closing - if empty, deletes the file ## Approach This is a simpler approach than PR #1793 (deferred file creation): - Files are still created at initialization (no changes to init path) - At cleanup, if a file is empty (0 bytes), it's deleted with an informational message - Minimal code change (1 file, ~12 lines) ## Test Results ``` $ ccextractor sample.ts --output-field both -o /tmp/test.srt ... Deleted empty output file: /tmp/test_2.srt ``` Only the file with actual captions remains. Fixes #1282 🤖 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:23:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2655