• 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

88.64
/commands/save.lua
1
---------
2
-- async schema save command
3

4
--- save a schematic asynchronously
5
-- @param playername the playername to use in messages
6
-- @param pos1 lower position to save
7
-- @param pos2 upper position to save
8
-- @param name the name of the schema
9
-- @param local_save save to the filesystem
10
-- @return a promise that resolves if the operation is complete
11
-- @return the job context
12
function blockexchange.save(playername, pos1, pos2, name, local_save)
2✔
13
        pos1, pos2 = blockexchange.sort_pos(pos1, pos2)
4✔
14

15
        local total_parts = blockexchange.count_schemaparts(pos1, pos2)
2✔
16
        local token = blockexchange.get_token(playername)
2✔
17
        local claims = blockexchange.get_claims(playername)
2✔
18
        local license = blockexchange.get_license(playername)
2✔
19
        local iterator = blockexchange.iterator(pos1, pos1, pos2)
2✔
20

21
        if not local_save and not token then
2✔
22
                return Promise.new():reject("not logged in")
×
23
        end
24

25
        local ctx = {
2✔
26
                type = "upload",
27
                local_save = local_save,
2✔
28
                playername = playername,
2✔
29
                username = claims and claims.username,
2✔
30
                schemaname = name,
2✔
31
                token = token,
2✔
32
                origin = pos1,
2✔
33
                pos1 = pos1,
2✔
34
                pos2 = pos2,
2✔
35
                iterator = iterator,
2✔
36
                current_pos = iterator(),
4✔
37
                current_part = 0,
38
                total_parts = total_parts,
2✔
39
                total_size = 0,
40
                progress_percent = 0,
41
                mod_names = {},
2✔
42
                promise = Promise.new()
4✔
43
        }
44

45
        local create_schema = {
2✔
46
                size_x = pos2.x - pos1.x + 1,
2✔
47
                size_y = pos2.y - pos1.y + 1,
2✔
48
                size_z = pos2.z - pos1.z + 1,
2✔
49
                description = "",
50
                license = license,
2✔
51
                name = name
2✔
52
        }
53

54
        if local_save then
2✔
55
                -- offline, local saving
56
                ctx.zipfile = io.open(blockexchange.get_local_filename(name), "wb")
2✔
57
                ctx.zip = mtzip.zip(ctx.zipfile)
2✔
58
                ctx.create_schema = create_schema
1✔
59

60
                -- start save worker with context
61
                blockexchange.save_worker(ctx)
2✔
62
        else
63
                -- online
64
                blockexchange.api.create_schema(token, create_schema):next(function(schema)
3✔
65
                        ctx.schema = schema
1✔
66
                        minetest.log("action", "[blockexchange] schema created with id: " .. schema.uid)
1✔
67

68
                        -- start save worker with context
69
                        blockexchange.save_worker(ctx)
1✔
70
                end):catch(function(err)
4✔
NEW
71
                        local msg = "[blockexchange] create schema failed: " ..
×
NEW
72
                                (err or "unknown") ..
×
73
                                ", you might have exceeded the upload limits"
74

75
                        minetest.log("error", msg)
×
76
                        ctx.promise:reject(msg)
×
77
                end)
78
        end
79

80
        return ctx.promise, ctx
2✔
81
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