+/* Finish up a partially-written cloud log segment and flush it to storage. */
+void bluesky_cloudlog_flush(BlueSkyFS *fs)
+{
+ BlueSkyCloudLogState *state = fs->log_state;
+ if (state->data == NULL || state->data->len == 0)
+ return;
+
+ /* TODO: Append some type of commit record to the log segment? */
+
+ g_print("Serializing %zd bytes of data to cloud\n", state->data->len);
+
+ BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store);
+ async->op = STORE_OP_PUT;
+ async->key = g_strdup_printf("log-%08d-%08d",
+ state->location.directory,
+ state->location.sequence);
+ async->data = bluesky_string_new_from_gstring(state->data);
+ bluesky_store_async_submit(async);
+ bluesky_store_async_wait(async);
+ bluesky_store_async_unref(async);
+
+ state->location.sequence++;
+ state->location.offset = 0;
+ state->data = g_string_new("");
+}
+