Rework caching of data blocks to eliminate double-caching.
[bluesky.git] / bluesky / serialize.c
index e453f49..a9e4182 100644 (file)
@@ -93,9 +93,11 @@ void bluesky_serialize_inode(GString *out, BlueSkyInode *inode)
         g_string_append_len(out, (gchar *)&size, sizeof(uint64_t));
         for (int i = 0; i < inode->blocks->len; i++) {
             BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
+            BlueSkyCloudID id;
+            memset(&id, 0, sizeof(id));
             if (b->ref != NULL)
-                g_string_append(out, b->ref);
-            g_string_append_c(out, '\0');
+                id = b->ref->id;
+            g_string_append_len(out, (const char *)&id, sizeof(id));
         }
         break;
     }
@@ -178,12 +180,15 @@ gboolean bluesky_deserialize_inode(BlueSkyInode *inode, const gchar *buf)
         g_array_set_size(inode->blocks,
                          (inode->size + BLUESKY_BLOCK_SIZE - 1)
                           / BLUESKY_BLOCK_SIZE);
+        // TODO
+#if 0
         for (int i = 0; i < inode->blocks->len; i++) {
             BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
             b->type = BLUESKY_BLOCK_REF;
             b->ref = g_strdup(buf);
             buf += strlen(b->ref) + 1;
         }
+#endif
         break;
 
     case BLUESKY_DIRECTORY: