[mythtv-users] [PATCH] Make it possible to delete programs that have no file anymore [again]

Tako Schotanus quintesse at palacio-cristal.com
Sat Jun 28 01:09:40 EDT 2003


IDIOT! For not testing all possibilities before sending the patch grrrrr

Sorry,
  -Tako

----------------------------------

Found out that if you delete a .nuv file you can't remove its entry from
the Recorded Programs listing.
The code would exit prematurely if it could not find the file and
therefore would not delete the program entry either.
This patch fixes that.

Cheers,
  -Tako

-------------- next part --------------
Index: mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.58
diff -r1.58 mainserver.cpp
722,738d721
<     QString fileprefix = gContext->GetFilePrefix();
<     QString filename = pginfo->GetRecordFilename(fileprefix);
<     QFile checkFile(filename);
< 
<     if (!checkFile.exists())
<     {
<        cerr << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
<             << " Strange.  File: " << filename << " doesn't exist." << endl;
< 
<        QStringList outputlist;
<        outputlist << "BAD: Tried to delete a file that was in "
<                      "the database but wasn't on the disk.";
<        WriteStringList(pbs->getSocket(), outputlist);
<        delete pginfo;
<        return;
<     }
< 
782,783c765,767
<     DeleteStruct *ds = new DeleteStruct;
<     ds->filename = filename;
---
>     QString fileprefix = gContext->GetFilePrefix();
>     QString filename = pginfo->GetRecordFilename(fileprefix);
>     QFile checkFile(filename);
785,788c769,779
<     pthread_t deletethread;
<     pthread_attr_t attr;
<     pthread_attr_init(&attr);
<     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
---
>     // Check if file exists
>     if (checkFile.exists())
>     {
>         // If so, let's delete it using a newly created deleter thread
>         DeleteStruct *ds = new DeleteStruct;
>         ds->filename = filename;
> 
>         pthread_t deletethread;
>         pthread_attr_t attr;
>         pthread_attr_init(&attr);
>         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
790c781,793
<     pthread_create(&deletethread, &attr, SpawnDelete, ds);
---
>         pthread_create(&deletethread, &attr, SpawnDelete, ds);
>     }
>     else
>     {
> 	// If not, output an error but continue as if nothing happened
>         cerr << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
>              << " Strange.  File: " << filename << " doesn't exist." << endl;
> 
>         QStringList outputlist;
>         outputlist << "BAD: Tried to delete a file that was in "
>                       "the database but wasn't on the disk.";
>         WriteStringList(pbs->getSocket(), outputlist);
>     }


More information about the mythtv-users mailing list