diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index 7a79aed5f..d8b56f854 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -449,7 +449,7 @@ bool readEventsFromFile(std::string &epgname, int &ev_count) return true; } -bool readEventsFromXMLTV(std::string &epgname, int &ev_count) +bool readEventsFromXMLTV(std::string &epgname, int &ev_count, bool delete_after) { xmlDocPtr event_parser = NULL; xmlNodePtr tv; @@ -563,6 +563,14 @@ bool readEventsFromXMLTV(std::string &epgname, int &ev_count) } xmlFreeDoc(event_parser); + + if (delete_after) + { + int ret = unlink(epgname.c_str()); + if (ret != 0) + printf("Failed to delete file: %s\n", epgname.c_str()); + } + return true; } @@ -712,10 +720,7 @@ void *insertEventsfromXMLTV(void * data) { if (!access(tmp_name.c_str(), R_OK)) { - readEventsFromXMLTV(tmp_name, ev_count); - int ret = unlink(tmp_name.c_str()); - if (ret != 0) - printf("Failed to delete file: %s\n", tmp_name.c_str()); + readEventsFromXMLTV(tmp_name, ev_count, true); } } else diff --git a/src/eitd/xmlutil.h b/src/eitd/xmlutil.h index bb5aee5a0..9f132bcbf 100644 --- a/src/eitd/xmlutil.h +++ b/src/eitd/xmlutil.h @@ -37,7 +37,7 @@ void *insertEventsfromFile(void * data); void *insertEventsfromXMLTV(void * data); bool readEventsFromFile(std::string &epgname, int &ev_count); -bool readEventsFromXMLTV(std::string &epgname, int &ev_count); +bool readEventsFromXMLTV(std::string &epgname, int &ev_count, bool delete_after = false); bool readEventsFromDir(std::string &epgdir, int &ev_count); void writeEventsToFile(const char *epgdir); t_channel_id getepgid(std::string epg_name);