Permalink
Browse files

Fix the 1299 DB upgrade (DeletedMaxAge update).

The 1299 upgrade modifies DeletedMaxAge for its new meaning, now that
AutoExpireInsteadOfDelete is always enabled.  Previously, 0 meant
"expire when out of disk space" and was the default value; but after
f78f999 , 0 means "expire immediately" and -1 means "expire when out of
disk space."  Both before and after f78f999, any positive value means
to expire recording files that many days after deletion.

However, the setting DeletedMaxAge was only ever written to the database
if the user enabled AutoExpireInsteadOfDelete (triggering the
DeletedExpireOptions TriggeredConfigurationGroup) and modified
DeletedMaxAge to some value other than its default of 0.  Therefore,
most users did not actually have a value for DeletedMaxAge in their
databases--whether they had enabled AutoExpireInsteadOfDelete or not.

The DB upgrade needs to change DeletedMaxAge to -1 if and only if
AutoExpireInsteadOfDelete is enabled and DeletedMaxAge has a value of 0
(or is still using the default).  Because of the condition on the
update, it did nothing for users with AutoExpireInsteadOfDelete enabled
but without a value for DeletedMaxAge in the database.  This resulted in
their systems changing from "expire when out of space" to "expire
immediately".

Thanks to Thomas Boehm and Peter on the mythtv-users mailing list for
noticing that their settings didn't carry over through the update.
  • Loading branch information...
sphery committed May 15, 2012
1 parent e464d29 commit abfced82a94d2644d1c4df3e332458e947092329
Showing with 9 additions and 0 deletions.
  1. +9 −0 mythtv/libs/libmythtv/dbcheck.cpp
@@ -1943,6 +1943,15 @@ NULL
if (dbver == "1298")
{
LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1299");
+
+ // DeletedMaxAge setting only exists if the user ever triggered the
+ // DeletedExpireOptions TriggeredConfigurationGroup (enabled
+ // AutoExpireInsteadOfDelete) and changed DeletedMaxAge from its
+ // default of zero, so "reset" it to ensure it's in the database before
+ // the update
+ QString deletedMaxAge = gCoreContext->GetSetting("DeletedMaxAge", "0");
+ gCoreContext->SaveSettingOnHost("DeletedMaxAge", deletedMaxAge, NULL);
+
QString queryStr;
if (gCoreContext->GetNumSetting("AutoExpireInsteadOfDelete", 0))
{

0 comments on commit abfced8

Please sign in to comment.