Fix wrong internaldate_time_t column
We had a bug in our DateTime to time_t conversion logic where all time_ts would end up in the year 3800. This fixes that, and repopulates the internaldate_time_t column with the new, correct time_t values. Closes: bgo #724335
This commit is contained in:
parent
aca1e53984
commit
4dc5d28c58
4 changed files with 13 additions and 2 deletions
|
|
@ -17,3 +17,4 @@ install(FILES version-014.sql DESTINATION ${SQL_DEST})
|
|||
install(FILES version-015.sql DESTINATION ${SQL_DEST})
|
||||
install(FILES version-016.sql DESTINATION ${SQL_DEST})
|
||||
install(FILES version-017.sql DESTINATION ${SQL_DEST})
|
||||
install(FILES version-018.sql DESTINATION ${SQL_DEST})
|
||||
|
|
|
|||
6
sql/version-018.sql
Normal file
6
sql/version-018.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
--
|
||||
-- Nuke the internaldate_time_t column, because it had the wrong values. It'll
|
||||
-- be repopulated in code, in imap-db-database.vala.
|
||||
--
|
||||
|
||||
UPDATE MessageTable SET internaldate_time_t = NULL;
|
||||
|
|
@ -93,6 +93,10 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
|
|||
case 15:
|
||||
post_upgrade_fix_localized_internaldates();
|
||||
break;
|
||||
|
||||
case 18:
|
||||
post_upgrade_populate_internal_date_time_t();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +206,7 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
|
|||
return "english";
|
||||
}
|
||||
|
||||
// Version 12.
|
||||
// Versions 12 and 18.
|
||||
private void post_upgrade_populate_internal_date_time_t() {
|
||||
try {
|
||||
exec_transaction(Db.TransactionType.RW, (cx) => {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public time_t datetime_to_time_t(DateTime datetime) {
|
|||
// month is 1-based in DateTime
|
||||
tm.month = Numeric.int_floor(datetime.get_month() - 1, 0);
|
||||
// Time's year is number of years after 1900
|
||||
tm.year = Numeric.int_floor(datetime.get_year() - 1900, 1900);
|
||||
tm.year = Numeric.int_floor(datetime.get_year() - 1900, 0);
|
||||
tm.isdst = datetime.is_daylight_savings() ? 1 : 0;
|
||||
|
||||
return tm.mktime();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue