diff --git a/pvr.hdhomerundvr/changelog.txt b/pvr.hdhomerundvr/changelog.txt index 0b856f15..a60242d1 100644 --- a/pvr.hdhomerundvr/changelog.txt +++ b/pvr.hdhomerundvr/changelog.txt @@ -1,3 +1,6 @@ +v1.2.2 (2017.08.02) + - Fix EPG update being aborted prematurely when requesting guide data from the past + v1.2.1 (2017.08.02) - Add "Disable Channel", "Add to Favorite Channels" and "Remove from Favorite Channels" Client Actions to channel context menus - Adapt to new backend discovery URLs (api.hdhomerun.com) diff --git a/src/database.cpp b/src/database.cpp index 2ccb0bb0..26dcdd1c 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -1396,6 +1396,10 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t if((instance == nullptr) || (callback == nullptr)) return; + // Prevent asking for anything older than 4 hours in the past (14400 = (60 * 60 * 4) = 4 hours) + time_t now = time(nullptr); + starttime = std::max(starttime, now - 14400); + // seriesid | title | starttime | endtime | synopsis | year | iconurl | genretype | originalairdate | seriesnumber | episodenumber | episodename auto sql = "with deviceauth(code) as (select group_concat(json_extract(data, '$.DeviceAuth'), '') from device) " "select json_extract(entry.value, '$.SeriesID') as seriesid, " @@ -1418,7 +1422,7 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t try { - do { + while(starttime < endtime) { // Bind the query parameters result = sqlite3_bind_int(statement, 1, channelid.value); @@ -1428,10 +1432,15 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t // Execute the SQL statement result = sqlite3_step(statement); - // If no rows were returned from the query, there is no more available guide data - // from the backend, break the loop even though endtime may not have been reached - if(result == SQLITE_DONE) break; + // If no rows were returned from the query and the start time is still in the past, + // fast-forward it to the current time and try again. Otherwise stop - no more data + if(result == SQLITE_DONE) { + + if(starttime < now) starttime = now; + else break; + } + // Process each row returned from the query (if any) while(result == SQLITE_ROW) { struct guideentry item; @@ -1459,8 +1468,7 @@ void enumerate_guideentries(sqlite3* instance, union channelid channelid, time_t // Reset the prepared statement so that it can be executed again result = sqlite3_reset(statement); if(result != SQLITE_OK) throw sqlite_exception(result); - - } while(starttime < endtime); + }; sqlite3_finalize(statement); // Finalize the SQLite statement } diff --git a/src/version.ini b/src/version.ini index 57f62da9..9f1d2623 100644 --- a/src/version.ini +++ b/src/version.ini @@ -8,4 +8,4 @@ Company=Michael G. Brehm Copyright= Product=zuki.pvr.hdhomerundvr -Version=1.2.1 +Version=1.2.2