• 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

83.02
/commands/load.lua
1
---------
2
-- async schema load command
3

4
--- load a schematic asynchronously
5
-- @param playername the playername to use in messages
6
-- @param pos1 lower position to load
7
-- @param username the username/owner of the schema
8
-- @param schemaname the name of the schema
9
-- @param[opt] local_load load from the filesystem
10
-- @param[opt] from_mtime start with block mtime
11
-- @return a promise that resolves if the operation is complete
12
-- @return the job context
13
function blockexchange.load(playername, pos1, username, schemaname, local_load, from_mtime)
2✔
14
        local ctx = {
2✔
15
                type = "download",
16
                local_load = local_load,
2✔
17
                playername = playername,
2✔
18
                username = username,
2✔
19
                schemaname = schemaname,
2✔
20
                pos1 = pos1,
2✔
21
                current_part = 0,
22
                progress_percent = 0,
23
                from_mtime = from_mtime or 0,
2✔
24
                promise = Promise.new()
4✔
25
        }
26

27
        if local_load then
2✔
28
                local filename = blockexchange.get_local_filename(schemaname)
1✔
29
                ctx.zipfile = io.open(filename, "rb")
1✔
30
                if not ctx.zipfile then
1✔
31
                        ctx.promise:reject("file not found: " .. filename)
×
32
                        return ctx.promise
×
33
                end
34
                local z, err_msg = mtzip.unzip(ctx.zipfile)
1✔
35
                if err_msg then
1✔
36
                        ctx.promise:reject("unzip error: " .. err_msg)
×
37
                        return ctx.promise
×
38
                end
39
                ctx.zip = z
1✔
40

41
                local schema_str
42
                schema_str, err_msg = ctx.zip:get("schema.json", true)
2✔
43
                if err_msg then
1✔
44
                        ctx.promise:reject("schema.json error: " .. err_msg)
×
45
                        return ctx.promise
×
46
                end
47
                local schema = minetest.parse_json(schema_str)
1✔
48

49
                local pos2 = vector.add(pos1, blockexchange.get_schema_size(schema))
2✔
50
                pos2 = vector.subtract(pos2, 1)
2✔
51

52
                local total_parts = blockexchange.count_schemaparts(pos1, pos2)
1✔
53

54
                ctx.pos2 = pos2
1✔
55
                ctx.origin = ctx.pos1
1✔
56

57
                ctx.iterator = blockexchange.iterator(ctx.origin, ctx.pos1, ctx.pos2)
2✔
58
                ctx.total_parts = total_parts
1✔
59
                ctx.schema = {}
1✔
60

61
                blockexchange.set_pos(2, playername, pos2)
1✔
62
                blockexchange.load_local_worker(ctx):next(function()
3✔
63
                        ctx.promise:resolve({
2✔
64
                                schema = ctx.schema,
1✔
65
                                last_schemapart = ctx.last_schemapart
1✔
66
                        })
67
                end):catch(function(err)
4✔
UNCOV
68
                        ctx.promise:reject(err)
×
69
                end)
70
        else
71
                blockexchange.api.get_schema_by_name(username, schemaname, true):next(function(schema)
3✔
72
                        if not schema then
1✔
UNCOV
73
                                ctx.promise:reject("Schema not found: '" .. username .. "/" .. schemaname .. "'")
×
UNCOV
74
                                return
×
75
                        end
76
                        ctx.pos2 = vector.add(pos1, blockexchange.get_schema_size(schema))
3✔
77
                        ctx.schema = schema
1✔
78
                        -- calculate origin point
79
                        ctx.origin = ctx.pos1
1✔
80
                        -- fetch total parts
81
                        return blockexchange.api.count_next_schemapart_by_mtime(schema.uid, ctx.from_mtime)
1✔
82
                end):next(function(total_parts)
3✔
83
                        if total_parts then
1✔
84
                                ctx.total_parts = total_parts
1✔
85
                                blockexchange.load_worker(ctx)
1✔
86
                        end
87
                end)
88
        end
89

90
        return ctx.promise, ctx
2✔
91
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