From 6c3d8bc02e8f4500c631a6089ad99f44ad8beca1 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Tue, 30 Sep 2008 23:09:16 +0000 Subject: [PATCH] fix corrupted epg.dat by using a faked version string and not writing the correct version string until all epg data has been flushed to disk --- lib/dvb/epgcache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp index 2a070473..1a07755f 100644 --- a/lib/dvb/epgcache.cpp +++ b/lib/dvb/epgcache.cpp @@ -1018,7 +1018,7 @@ void eEPGCache::save() { unsigned int magic = 0x98765432; fwrite( &magic, sizeof(int), 1, f); - const char *text = "ENIGMA_EPG_V7"; + const char *text = "UNFINISHED_V7"; fwrite( text, 13, 1, f ); int size = eventDB.size(); fwrite( &size, sizeof(int), 1, f ); @@ -1065,6 +1065,11 @@ void eEPGCache::save() } } #endif + // write version string after binary data + // has been written to disk. + fsync(fileno(f)); + fseek(f, sizeof(int), SEEK_SET); + fwrite("ENIGMA_EPG_V7", 13, 1, f); fclose(f); #if 0 unsigned char md5[16]; -- 2.30.2