Skip to content

Commit 0260b92

Browse files
committed
release: v0.8.0
1 parent dfc22d3 commit 0260b92

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

src/install.zig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn downloadTarball(alloc: Allocator, io: Io, client: *Client, tb_url: []cons
107107
var req = make_request(client, io, tarball_uri);
108108
defer req.?.deinit();
109109
if (req == null) {
110-
std.log.err("Failed fetching the install tarball. Exitting (1)...", .{});
110+
std.log.err("Failed fetching the install tarball. Exiting (1)...", .{});
111111
std.process.exit(1);
112112
}
113113

@@ -122,6 +122,17 @@ pub fn downloadTarball(alloc: Allocator, io: Io, client: *Client, tb_url: []cons
122122
var redir_buf: [1024]u8 = undefined;
123123
var response = try req.?.receiveHead(&redir_buf);
124124

125+
if (response.head.status.class() != .success) {
126+
std.log.err("HTTP error: {s} ({d})", .{ response.head.reason, @intFromEnum(response.head.status) });
127+
return error.HttpError;
128+
}
129+
130+
var active_tarball_size = tarball_size;
131+
if (tarball_size > 0 and response.head.status != .partial_content) {
132+
active_tarball_size = 0;
133+
try tb_writer.seekTo(0);
134+
}
135+
125136
var reader = response.reader(&.{});
126137

127138
var buff: [1024]u8 = undefined;
@@ -183,7 +194,7 @@ pub fn get_json_dslist(io: Io, client: *Client) anyerror!JsonResponse {
183194
var req = make_request(client, io, uri);
184195
defer req.?.deinit();
185196
if (req == null) {
186-
std.log.err("Failed fetching the index. Exitting (1)...", .{});
197+
std.log.err("Failed fetching the index. Exiting (1)...", .{});
187198
std.process.exit(1);
188199
}
189200

src/update-self.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn read_github_releases_data(alloc: Allocator, io: Io, client: *Client) !json.Pa
117117
defer req.?.deinit();
118118

119119
if (req == null) {
120-
std.log.err("Failed fetching the install tarball. Exitting (1)...", .{});
120+
std.log.err("Failed fetching the install tarball. Exiting (1)...", .{});
121121
std.process.exit(1);
122122
}
123123
req.?.extra_headers = &.{ http.Header{ .name = "Accept", .value = "application/vnd.github+json" }, http.Header{ .name = "X-GitHub-Api-Version", .value = "2022-11-28" } };

src/zigverm-setup/main.zig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn download_tarball(
147147
var req = make_request(client, io, tarball_uri);
148148
defer req.?.deinit();
149149
if (req == null) {
150-
std.log.err("Failed fetching the install tarball. Exitting (1)...", .{});
150+
std.log.err("Failed fetching the install tarball. Exiting (1)...", .{});
151151
std.process.exit(1);
152152
}
153153

@@ -162,6 +162,17 @@ fn download_tarball(
162162
var redir_buf: [1024]u8 = undefined;
163163
var response = try req.?.receiveHead(&redir_buf);
164164

165+
if (response.head.status.class() != .success) {
166+
std.log.err("HTTP error: {s} ({d})", .{ response.head.reason, @intFromEnum(response.head.status) });
167+
return error.HttpError;
168+
}
169+
170+
var active_tarball_size = tarball_size;
171+
if (tarball_size > 0 and response.head.status != .partial_content) {
172+
active_tarball_size = 0;
173+
try tb_writer.seekTo(0);
174+
}
175+
165176
var reader = response.reader(&.{});
166177

167178
var buff: [1024]u8 = undefined;
@@ -205,7 +216,7 @@ fn read_github_releases_data(alloc: std.mem.Allocator, io: Io, client: *Client)
205216
defer req.?.deinit();
206217

207218
if (req == null) {
208-
std.log.err("Failed fetching the install tarball. Exitting (1)...", .{});
219+
std.log.err("Failed fetching the install tarball. Exiting (1)...", .{});
209220
std.process.exit(1);
210221
}
211222
req.?.extra_headers = &.{ http.Header{ .name = "Accept", .value = "application/vnd.github+json" }, http.Header{ .name = "X-GitHub-Api-Version", .value = "2022-11-28" } };

0 commit comments

Comments
 (0)