Restart journal sequence numbering properly.
[bluesky.git] / bluesky / cloudlog.c
index c6c2735..c4cb1ae 100644 (file)
@@ -295,19 +295,20 @@ BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log,
     GString *data3 = g_string_new("");
     bluesky_serialize_cloudlog(log, data1, data2, data3);
 
-    /* TODO: Right now offset/size are set to the raw data, but we should add
-     * header parsing to the code which loads objects back in. */
     log->location = state->location;
     log->location.offset = state->data->len;
     log->data_size = data1->len;
 
     struct cloudlog_header header;
     memcpy(header.magic, CLOUDLOG_MAGIC, 4);
+    memset(header.crypt_auth, sizeof(header.crypt_auth), 0);
+    memset(header.crypt_iv, sizeof(header.crypt_iv), 0);
     header.type = log->type + '0';
     header.size1 = GUINT32_TO_LE(data1->len);
     header.size2 = GUINT32_TO_LE(data2->len);
     header.size3 = GUINT32_TO_LE(data3->len);
     header.id = log->id;
+    header.inum = GUINT64_TO_LE(log->inum);
 
     g_string_append_len(state->data, (const char *)&header, sizeof(header));
     g_string_append_len(state->data, data1->str, data1->len);
@@ -323,6 +324,8 @@ BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log,
                                                         log->inum, 1);
         entry->id = log->id;
         entry->location = log->location;
+        entry->item = log;
+        bluesky_cloudlog_ref(entry->item);
         g_mutex_unlock(fs->lock);
     }