mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
fuzzer web ui: resolve cwd in sources.tar
because the wasm code needs to string match against debug information
This commit is contained in:
parent
38227e9289
commit
bfc2ee03e5
@ -485,6 +485,8 @@ fn serveSourcesTar(ws: *WebServer, request: *std.http.Server.Request) !void {
|
||||
};
|
||||
std.mem.sortUnstable(Build.Cache.Path, deduped_paths, SortContext{}, SortContext.lessThan);
|
||||
|
||||
var cwd_cache: ?[]const u8 = null;
|
||||
|
||||
for (deduped_paths) |joined_path| {
|
||||
var file = joined_path.root_dir.handle.openFile(joined_path.sub_path, .{}) catch |err| {
|
||||
log.err("failed to open {}: {s}", .{ joined_path, @errorName(err) });
|
||||
@ -506,7 +508,10 @@ fn serveSourcesTar(ws: *WebServer, request: *std.http.Server.Request) !void {
|
||||
|
||||
var file_header = std.tar.output.Header.init();
|
||||
file_header.typeflag = .regular;
|
||||
try file_header.setPath(joined_path.root_dir.path orelse ".", joined_path.sub_path);
|
||||
try file_header.setPath(
|
||||
joined_path.root_dir.path orelse try memoizedCwd(arena, &cwd_cache),
|
||||
joined_path.sub_path,
|
||||
);
|
||||
try file_header.setSize(stat.size);
|
||||
try file_header.updateChecksum();
|
||||
try w.writeAll(std.mem.asBytes(&file_header));
|
||||
@ -519,6 +524,13 @@ fn serveSourcesTar(ws: *WebServer, request: *std.http.Server.Request) !void {
|
||||
try response.end();
|
||||
}
|
||||
|
||||
fn memoizedCwd(arena: Allocator, opt_ptr: *?[]const u8) ![]const u8 {
|
||||
if (opt_ptr.*) |cached| return cached;
|
||||
const result = try std.process.getCwdAlloc(arena);
|
||||
opt_ptr.* = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
const cache_control_header: std.http.Header = .{
|
||||
.name = "cache-control",
|
||||
.value = "max-age=0, must-revalidate",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user