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

blockexchange / blockexchange / 13114295314

03 Feb 2025 01:12PM UTC coverage: 48.384% (+0.2%) from 48.213%
13114295314

push

github

BuckarooBanzay
finalize cleanup

5 of 5 new or added lines in 1 file covered. (100.0%)

15 existing lines in 4 files now uncovered.

988 of 2042 relevant lines covered (48.38%)

1213.18 hits per line

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

65.22
/worker/load_worker.lua
1
local has_monitoring = minetest.get_modpath("monitoring")
1✔
2

3
local downloaded_blocks
4

5
if has_monitoring then
1✔
6
        downloaded_blocks = monitoring.counter(
×
7
                "blockexchange_downloaded_blocks",
8
                "number of successfully downloaded mapblocks"
9
        )
10
end
11

12
local function place_schemapart(schemapart, ctx)
13
        if not schemapart then
5✔
14
                blockexchange.log("action", "Download complete with " .. ctx.total_parts .. " parts")
1✔
15

16
                -- fetch updated schema and register area for future updates
17
                blockexchange.register_area(ctx.pos1, ctx.pos2, ctx.playername, ctx.username, ctx.schema)
1✔
18

19
                ctx.promise:resolve({
2✔
20
                        schema = ctx.schema,
1✔
21
                        last_schemapart = ctx.last_schemapart
1✔
22
                })
23
                return
1✔
24
        end
25

26
        -- increment stats
27
        ctx.current_part = ctx.current_part + 1
4✔
28
        ctx.progress_percent = math.floor(ctx.current_part / ctx.total_parts * 100 * 10) / 10
4✔
29

30
        local pos1 = blockexchange.place_schemapart(schemapart, ctx.origin)
4✔
31
        minetest.log("action", "[blockexchange] Download of part " .. minetest.pos_to_string(pos1) .. " completed")
8✔
32

33
        if has_monitoring then
4✔
34
                downloaded_blocks.inc(1)
×
35
        end
36

37
        ctx.last_schemapart = schemapart
4✔
38
        minetest.after(blockexchange.min_delay, blockexchange.load_worker, ctx)
4✔
39

40
        -- TODO: overwrite inworld parts if downloaded part is air-only
41
end
42

43
local function schedule_retry(ctx, err)
44
        local msg = "[blockexchange] download schemapart failed: " .. (err or "unkown") .. " retrying..."
×
45
        minetest.log("error", msg)
×
46

47
        -- wait a couple seconds
48
        minetest.after(5, blockexchange.load_worker, ctx)
×
49
end
50

51

52
function blockexchange.load_worker(ctx)
2✔
53
        if ctx.cancel then
5✔
54
                ctx.promise:reject("canceled")
×
55
                return
×
56
        end
57

58
        if ctx.from_mtime > 0 then
5✔
59
                -- online, incremental download by mtime
UNCOV
60
                local mtime = ctx.from_mtime
×
UNCOV
61
                if ctx.last_schemapart then
×
62
                        -- start from last schema part
UNCOV
63
                        mtime = ctx.last_schemapart.mtime
×
64
                end
UNCOV
65
                blockexchange.api.get_next_schemapart_by_mtime(ctx.schema.uid,  mtime):next(function(schemapart)
×
UNCOV
66
                        place_schemapart(schemapart, ctx, false)
×
UNCOV
67
                end):catch(function(err)
×
UNCOV
68
                        schedule_retry(ctx, err)
×
69
                end)
70
        else
71
                -- online, full download
72
                if not ctx.last_schemapart then
5✔
73
                        -- start from the beginning
74
                        blockexchange.api.get_first_schemapart(ctx.schema.uid):next(function(schemapart)
3✔
75
                                place_schemapart(schemapart, ctx, false)
1✔
76
                        end):catch(function(err)
4✔
UNCOV
77
                                schedule_retry(ctx, err)
×
78
                        end)
79
                else
80
                        -- start from last position
81
                        local pos = {
4✔
82
                                x = ctx.last_schemapart.offset_x,
4✔
83
                                y = ctx.last_schemapart.offset_y,
4✔
84
                                z = ctx.last_schemapart.offset_z
4✔
85
                        }
86
                        blockexchange.api.get_next_schemapart(ctx.schema.uid, pos):next(function(schemapart)
12✔
87
                                place_schemapart(schemapart, ctx, false)
4✔
88
                        end):catch(function(err)
16✔
UNCOV
89
                                schedule_retry(ctx, err)
×
90
                        end)
91
                end
92
        end
93
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