aboutsummaryrefslogtreecommitdiff
path: root/src/fs.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs.zig')
-rw-r--r--src/fs.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/fs.zig b/src/fs.zig
index 3936ea933..e59d24b6f 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -16,7 +16,7 @@ const hash_map = @import("hash_map.zig");
pub const Preallocate = struct {
pub const Counts = struct {
pub const dir_entry: usize = 512;
- pub const files: usize = 1024;
+ pub const files: usize = 4096;
};
};
@@ -810,7 +810,7 @@ pub const FileSystem = struct {
) !File {
FileSystem.setMaxFd(file.handle);
- if (FeatureFlags.disable_filesystem_cache) {
+ if (comptime FeatureFlags.disable_filesystem_cache) {
_ = std.os.fcntl(file.handle, std.os.F_NOCACHE, 1) catch 0;
}
@@ -820,6 +820,18 @@ pub const FileSystem = struct {
return err;
});
+ // Skip the pread call for empty files
+ // Otherwise will get out of bounds errors
+ // plus it's an unnecessary syscall
+ if (size == 0) {
+ if (comptime use_shared_buffer) {
+ shared_buffer.reset();
+ return File{ .path = Path.init(path), .contents = shared_buffer.list.items };
+ } else {
+ return File{ .path = Path.init(path), .contents = "" };
+ }
+ }
+
var file_contents: []u8 = undefined;
// When we're serving a JavaScript-like file over HTTP, we do not want to cache the contents in memory