aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/message.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2010-01-09 11:13:12 -0800
committerGravatar Carl Worth <cworth@cworth.org>2010-01-09 11:13:12 -0800
commitd12801c8b4d04a50fcb912b75017244fb09658e8 (patch)
tree8212267ab21f5e3f9fe274eaf53b58409445ada2 /lib/message.cc
parent5fe5e802ab3101a375ec1262770955904e169e47 (diff)
lib: Split the database upgrade into two phases for safer operation.
The first phase copies data from the old format to the new format without deleting anything. This allows an old notmuch to still use the database if the upgrade process gets interrupted. The second phase performs the deletion (after updating the database version number). If the second phase is interrupted, there will be some unused data in the database, but it shouldn't cause any actual harm.
Diffstat (limited to 'lib/message.cc')
-rw-r--r--lib/message.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/message.cc b/lib/message.cc
index baeaa469..1cda55a1 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -416,22 +416,16 @@ _notmuch_message_add_filename (notmuch_message_t *message,
return NOTMUCH_STATUS_SUCCESS;
}
-/* Move the filename from the data field (as it was in database format
- * version 0) to a file-direntry term instead (as in database format
- * version 1).
- */
-void
-_notmuch_message_upgrade_filename_storage (notmuch_message_t *message)
+char *
+_notmuch_message_talloc_copy_data (notmuch_message_t *message)
{
- char *filename;
+ return talloc_strdup (message, message->doc.get_data ().c_str ());
+}
- filename = talloc_strdup (message, message->doc.get_data ().c_str ());
- if (filename && *filename != '\0') {
- _notmuch_message_add_filename (message, filename);
- message->doc.set_data ("");
- _notmuch_message_sync (message);
- }
- talloc_free (filename);
+void
+_notmuch_message_clear_data (notmuch_message_t *message)
+{
+ message->doc.set_data ("");
}
const char *