diff --git a/deserialize_chunk.lua b/deserialize_chunk.lua index 263b162..9126880 100644 --- a/deserialize_chunk.lua +++ b/deserialize_chunk.lua @@ -4,6 +4,9 @@ local param1, param2, node_data -- deserializes the chunk to the world function mapsync.deserialize_chunk(chunk_pos, filename, vmanip) + -- TODO: check for key.json + -- mapsync.parse_chunk_key(filename) + -- if encrypted: decrypt if key available or move to pending queue local chunk, err_msg = mapsync.parse_chunk(filename) if not chunk then return false, err_msg diff --git a/serialize_chunk.lua b/serialize_chunk.lua index 64b369c..b738b82 100644 --- a/serialize_chunk.lua +++ b/serialize_chunk.lua @@ -41,6 +41,9 @@ function mapsync.serialize_chunk(chunk_pos, filename) return true end + -- get key manifest from zip before overwriting + local key_manifest = mapsync.parse_chunk_key(filename) + -- open zip for writing local f = global_env.io.open(filename, "wb") if not f then @@ -92,9 +95,15 @@ function mapsync.serialize_chunk(chunk_pos, filename) end end - zip:add("mapdata.bin", table.concat(mapdata)) - zip:add("metadata.json", minetest.write_json(metadata)) - zip:add("manifest.json", minetest.write_json(manifest)) + if key_manifest then + -- encrypt and add key manifest + -- TODO + else + -- store plain + zip:add("mapdata.bin", table.concat(mapdata)) + zip:add("metadata.json", minetest.write_json(metadata)) + zip:add("manifest.json", minetest.write_json(manifest)) + end zip:close() f:close()