Browse files

Make mythcommflag terminate early on 0-byte files

I had a rash of 0-byte files the other day, and I found that mythcommflag
would sit and spin trying to create some initial buffers, or something along
those lines.  This change makes it check if the file is 0 bytes.  If it is,
it will immediately quit with an error, rather than indefinitely try to
grind on it.

This may need some tweaking to deal with commflagging while recording as it
could cause a race condition if the file has no data at the moment that
mythcommflag starts.
  • Loading branch information...
1 parent e70c3ae commit 61f07e0d4f1e115d97faaf83506a0738e0cb2e96 @Beirdo Beirdo committed Mar 10, 2011
Showing with 9 additions and 0 deletions.
  1. +9 −0 mythtv/programs/mythcommflag/main.cpp
@@ -752,6 +752,15 @@ static int FlagCommercials(
QString filename = get_filename(program_info);
+ QFile file(filename);
+ if (file.size() == 0)
+ {
+ VERBOSE(VB_IMPORTANT, QString("File %1 is zero-byte, aborting.")
+ .arg(filename));
+ global_program_info = NULL;
+ }
RingBuffer *tmprbuf = RingBuffer::Create(filename, false);
if (!tmprbuf)

0 comments on commit 61f07e0

Please sign in to comment.