@@ -132,12 +132,12 @@ pub fn download_tarball(alloc: Allocator, client: *Client, tb_url: []const u8, t
132132 const tbw_intf = & tb_writer .interface ;
133133 while (tarball_size_d + dlnow .load (AtomicOrder .monotonic ) <= total_size_d ) {
134134 const len = try reader .readSliceShort (& buff );
135- if (len == 0 ) {
136- break ;
137- }
138135 _ = try tbw_intf .write (buff [0.. len ]);
139-
140136 _ = dlnow .fetchAdd (@floatFromInt (len ), AtomicOrder .monotonic );
137+
138+ if (len < buff .len ) {
139+ break ;
140+ }
141141 }
142142 progress_thread .join ();
143143 try tb_writer .end ();
@@ -184,11 +184,15 @@ pub fn get_json_dslist(client: *Client) anyerror!JsonResponse {
184184 try req .? .sendBodiless ();
185185 var response = try req .? .receiveHead (&.{});
186186
187- var json_buff : [1024 * 100 ]u8 = undefined ;
188- const res_r = response .reader (&.{});
189- const bytes_read = try res_r .readSliceShort (& json_buff );
187+ var tbuf : [1024 ]u8 = undefined ;
188+ var dbuf : [std .compress .flate .max_window_len ]u8 = undefined ;
189+ var json_buf : [1024 * 100 ]u8 = undefined ;
190+ var decomp = http.Decompress { .none = undefined };
191+
192+ const res_r = response .readerDecompressing (& tbuf , & decomp , & dbuf );
193+ const bytes_read = try res_r .readSliceShort (& json_buf );
190194
191- return JsonResponse { .body = json_buff , .length = bytes_read };
195+ return JsonResponse { .body = json_buf , .length = bytes_read };
192196}
193197
194198pub fn make_request (client : * Client , uri : std.Uri ) ? Client.Request {
@@ -226,11 +230,11 @@ pub fn check_hash(hashstr: *const [64]u8, reader: *std.Io.Reader) !bool {
226230
227231inline fn extract_xz (alloc : Allocator , dirs : CommonPaths , rel : Release , reader : * std.Io.Reader ) ! void {
228232 // HACK: Use the older interface until Zig upgrades this
229- const r = reader .adaptToOldInterface ();
230- var xz = try std .compress .xz .decompress (alloc , r );
233+ const buff = try alloc .alloc (u8 , 4096 );
234+ var xz = try std .compress .xz .Decompress .init (reader , alloc , buff );
235+ defer alloc .free (xz .takeBuffer ());
231236 const release_dir = try dirs .install_dir .makeOpenPath (try release_name (alloc , rel ), .{});
232- var adpt = xz .reader ().adaptToNewApi (&.{});
233- const intf = & adpt .new_interface ;
237+ const intf = & xz .reader ;
234238 try std .tar .pipeToFileSystem (release_dir , intf , .{ .strip_components = 1 });
235239}
236240
0 commit comments