erase /hdd/epg.dat after read
[vuplus_dvbapp] / lib / dvb / epgcache.cpp
index afbc6e0..acdc9a9 100644 (file)
@@ -226,7 +226,11 @@ eEPGCache::eEPGCache()
        if (!res_mgr)
                eDebug("[eEPGCache] no resource manager !!!!!!!");
        else
+       {
                res_mgr->connectChannelAdded(slot(*this,&eEPGCache::DVBChannelAdded), m_chanAddedConn);
+               if (eDVBLocalTimeHandler::getInstance()->ready())
+                       timeUpdated();
+       }
        instance=this;
 }
 
@@ -857,8 +861,9 @@ void eEPGCache::thread()
 
 void eEPGCache::load()
 {
-       singleLock s(cache_lock);
-       FILE *f = fopen("/hdd/epg.dat", "r");
+       unlink("/hdd/epg.dat.$$$");
+       rename("/hdd/epg.dat", "/hdd/epg.dat.$$$");
+       FILE *f = fopen("/hdd/epg.dat.$$$", "r");
        if (f)
        {
                int size=0;
@@ -888,12 +893,14 @@ void eEPGCache::load()
                        {
                                eDebug("[EPGC] epg file has incorrect byte order.. dont read it");
                                fclose(f);
+                               unlink("/hdd/epg.dat.$$$");
                                return;
                        }
                        char text1[13];
                        fread( text1, 13, 1, f);
                        if ( !strncmp( text1, "ENIGMA_EPG_V7", 13) )
                        {
+                               singleLock s(cache_lock);
                                fread( &size, sizeof(int), 1, f);
                                while(size--)
                                {
@@ -965,6 +972,7 @@ void eEPGCache::load()
                        fclose(f);
                }
        }
+       unlink("/hdd/epg.dat.$$$");
 }
 
 void eEPGCache::save()