[geary] Fix wrong internaldate_time_t column
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix wrong internaldate_time_t column
- Date: Sat, 15 Feb 2014 00:07:36 +0000 (UTC)
commit 4dc5d28c58977e78adc1494786b5c3552b983594
Author: Charles Lindsay <chaz yorba org>
Date: Fri Feb 14 16:06:10 2014 -0800
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
sql/CMakeLists.txt | 1 +
sql/version-018.sql | 6 ++++++
src/engine/imap-db/imap-db-database.vala | 6 +++++-
src/engine/util/util-time.vala | 2 +-
4 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index dffda06..c206d2c 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -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})
diff --git a/sql/version-018.sql b/sql/version-018.sql
new file mode 100644
index 0000000..eda5126
--- /dev/null
+++ b/sql/version-018.sql
@@ -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;
diff --git a/src/engine/imap-db/imap-db-database.vala b/src/engine/imap-db/imap-db-database.vala
index a4a8a8a..f9ce635 100644
--- a/src/engine/imap-db/imap-db-database.vala
+++ b/src/engine/imap-db/imap-db-database.vala
@@ -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) => {
diff --git a/src/engine/util/util-time.vala b/src/engine/util/util-time.vala
index 0a52fb4..3c44cc8 100644
--- a/src/engine/util/util-time.vala
+++ b/src/engine/util/util-time.vala
@@ -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();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]