.off = offsetof(epggrab_conf_t, epgdb_periodicsave),
.group = 1,
},
+ {
+ .type = PT_BOOL,
+ .id = "epgdb_saveafterimport",
+ .name = N_("Save EPG to disk after xmltv import"),
+ .desc = N_("Writes the current in-memory EPG database to disk "
+ "shortly after an xmltv import has completed, so should a crash/unexpected "
+ "shutdown occur EPG data is saved "
+ "(re-read on next startup)."),
+ .off = offsetof(epggrab_conf_t, epgdb_saveafterimport),
+ .group = 1,
+ },
{
.type = PT_STR,
.id = "cron",
epggrab_conf.channel_renumber = 0;
epggrab_conf.channel_reicon = 0;
epggrab_conf.epgdb_periodicsave = 0;
+ epggrab_conf.epgdb_saveafterimport = 0;
epggrab_cron_multi = NULL;
#include "epg.h"
#include "epggrab.h"
#include "epggrab/private.h"
+extern gtimer_t epggrab_save_timer;
/* **************************************************************************
* Module Access
tvhinfo(mod->subsys, "%s: broadcasts tot=%5d new=%5d mod=%5d",
mod->id, stats.broadcasts.total, stats.broadcasts.created,
stats.broadcasts.modified);
+
+ /* Now we've parsed, do we need to save? */
+ if (save && epggrab_conf.epgdb_saveafterimport) {
+ tvhinfo(mod->subsys, "%s: scheduling save epg timer", mod->id);
+ pthread_mutex_lock(&global_lock);
+ /* Disarm any existing timer first (from a periodic save). */
+ gtimer_disarm(&epggrab_save_timer);
+ /* Reschedule for a few minutes away so if the user is
+ * refreshing from multiple xmltv sources we will give time for
+ * them to all complete before persisting, rather than persisting
+ * immediately after a parse.
+ *
+ * If periodic saving is enabled then the callback will then
+ * rearm the timer for x hours after the previous save.
+ */
+ gtimer_arm_rel(&epggrab_save_timer, epg_save_callback, NULL,
+ 60 * 2);
+ pthread_mutex_unlock(&global_lock);
+ }
}
/* **************************************************************************