• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

blockexchange / blockexchange / 13110168475

03 Feb 2025 09:18AM UTC coverage: 48.213% (+0.6%) from 47.564%
13110168475

push

github

BuckarooBanzay
http/json overhaul

51 of 102 new or added lines in 14 files covered. (50.0%)

1 existing line in 1 file now uncovered.

985 of 2043 relevant lines covered (48.21%)

1734.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.33
/worker/save_update_worker.lua
1

2
local function shift(ctx)
3
        ctx.current_pos, ctx.rel_pos, ctx.progress = ctx.iterator()
×
4

5
        -- increment stats
6
        ctx.current_part = ctx.current_part + 1
×
7
        ctx.progress_percent = math.floor(ctx.progress * 100 * 10) / 10
×
8
end
9

10
function blockexchange.save_update_worker(ctx)
2✔
11
        if ctx.cancel then
×
12
                ctx.promise:reject("canceled")
×
13
                return
×
14
        end
15

16
        if not ctx.token then
×
17
                ctx.promise:reject("no token found")
×
18
                return
×
19
        end
20

21
        if not ctx.current_pos then
×
22
                -- create an array with mod names
23
                local mod_names = {}
×
24
                for k in pairs(ctx.mod_names) do
×
25
                        table.insert(mod_names, k)
×
26
                end
27

28
                blockexchange.api.create_schemamods(ctx.token, ctx.schema_uid, mod_names):next(function()
×
29
                        local msg = "[blockexchange] Save-update complete with " .. ctx.total_parts .. " parts"
×
30
                        minetest.log("action", msg)
×
31
                        ctx.promise:resolve(ctx.total_parts)
×
NEW
32
                end):catch(function(err)
×
NEW
33
                        local msg = "[blockexchange] mod-update failed: " .. (err or "unkown")
×
34
                        minetest.log("error", msg)
×
35
                        ctx.promise:reject(msg)
×
36
                end)
37
                return
×
38
        end
39

40
        local start = minetest.get_us_time()
×
41

42
        local pos2 = vector.add(ctx.current_pos, 15)
×
43
        pos2.x = math.min(pos2.x, ctx.pos2.x)
×
44
        pos2.y = math.min(pos2.y, ctx.pos2.y)
×
45
        pos2.z = math.min(pos2.z, ctx.pos2.z)
×
46

47
        local data, node_count = blockexchange.serialize_part(ctx.current_pos, pos2)
×
48

49
        -- collect mod count info
50
        blockexchange.collect_node_count(node_count, ctx.mod_names)
×
51

52
        local diff = minetest.get_us_time() - start
×
53
        local relative_pos = vector.subtract(ctx.current_pos, ctx.origin)
×
54

55
        -- package data properly over the wire
56
        local schemapart = {
×
57
                schema_uid = ctx.schema_uid,
58
                offset_x = relative_pos.x,
59
                offset_y = relative_pos.y,
60
                offset_z = relative_pos.z,
61
                data = minetest.encode_base64(blockexchange.compress_data(data)),
62
                metadata = minetest.encode_base64(blockexchange.compress_metadata(data))
×
63
        }
64

65
        -- upload part online
66
        blockexchange.api.create_schemapart(ctx.token, schemapart):next(function()
×
67
                minetest.log("action", "[blockexchange] Save-update of part " .. minetest.pos_to_string(ctx.current_pos) ..
×
68
                " completed (processing took " .. diff .. " micros)")
×
69

70
                shift(ctx)
×
71
                minetest.after(blockexchange.min_delay, blockexchange.save_update_worker, ctx)
×
NEW
72
        end):catch(function(err)
×
NEW
73
                local msg = "[blockexchange] create schemapart failed: " .. (err or "unkown") ..
×
74
                " retrying..."
75
                minetest.log("error", msg)
×
76
                -- wait a couple seconds
77
                minetest.after(5, blockexchange.save_update_worker, ctx)
×
78
        end)
79
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc