Skip to content

Commit d7bf608

Browse files
committed
Fetch: make FetchStream live longer
1 parent 6244f5c commit d7bf608

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Package/Fetch.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,17 +1092,17 @@ fn initResource(f: *Fetch, uri: std.Uri, resource: *Resource, reader_buffer: []u
10921092

10931093
var want_oid_buf: [git.Oid.max_formatted_length]u8 = undefined;
10941094
_ = std.fmt.bufPrint(&want_oid_buf, "{f}", .{want_oid}) catch unreachable;
1095-
var fetch_stream: git.Session.FetchStream = undefined;
1096-
session.fetch(&fetch_stream, &.{&want_oid_buf}, reader_buffer) catch |err| {
1097-
return f.fail(f.location_tok, try eb.printString("unable to create fetch stream: {t}", .{err}));
1098-
};
1099-
errdefer fetch_stream.deinit();
1100-
11011095
resource.* = .{ .git = .{
11021096
.session = session,
1103-
.fetch_stream = fetch_stream,
1097+
.fetch_stream = undefined,
11041098
.want_oid = want_oid,
11051099
} };
1100+
const fetch_stream = &resource.git.fetch_stream;
1101+
session.fetch(fetch_stream, &.{&want_oid_buf}, reader_buffer) catch |err| {
1102+
return f.fail(f.location_tok, try eb.printString("unable to create fetch stream: {t}", .{err}));
1103+
};
1104+
errdefer fetch_stream.deinit(fetch_stream);
1105+
11061106
return;
11071107
}
11081108

0 commit comments

Comments
 (0)