generated from general-packages/pika-pkg-template
Fix issues when /proc/stat gets too large
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 49s
All checks were successful
PikaOS Package Build & Release (amd64-v3) / build (push) Successful in 49s
This commit is contained in:
parent
3863ab5adc
commit
a281ba0bd0
2
.github/release-nest-v3
vendored
2
.github/release-nest-v3
vendored
@ -1 +1 @@
|
||||
2
|
||||
1
|
@ -1,4 +1,4 @@
|
||||
pikafetch (0.3.0-101pika4) pika; urgency=medium
|
||||
pikafetch (0.3.0-101pika5) pika; urgency=medium
|
||||
|
||||
* Multiple disk support, add caching of GPU and packages info
|
||||
|
||||
|
@ -271,15 +271,15 @@ fn getBootTime() !i64 {
|
||||
const file = try fs.openFileAbsolute("/proc/stat", .{});
|
||||
defer file.close();
|
||||
|
||||
var buffer: [4096]u8 = undefined;
|
||||
const bytes_read = try file.readAll(&buffer);
|
||||
const content = buffer[0..bytes_read];
|
||||
var buf: [32768]u8 = undefined;
|
||||
const bytes_read = try file.readAll(&buf);
|
||||
const content = buf[0..bytes_read];
|
||||
|
||||
var lines = std.mem.splitScalar(u8, content, '\n');
|
||||
while (lines.next()) |line| {
|
||||
if (std.mem.startsWith(u8, line, "btime ")) {
|
||||
const time_str = std.mem.trim(u8, line["btime ".len..], " \t\r\n");
|
||||
return try std.fmt.parseInt(i64, time_str, 10);
|
||||
if (std.mem.startsWith(u8, line, "btime")) {
|
||||
const time_str = std.mem.trim(u8, line["btime".len..], " \t\r\n");
|
||||
return std.fmt.parseInt(i64, time_str, 10) catch return error.InvalidBootTime;
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ fn isCacheValid(cache_path: []const u8) !bool {
|
||||
defer cache_file.close();
|
||||
|
||||
const cache_stat = try cache_file.stat();
|
||||
const boot_time = try getBootTime();
|
||||
const boot_time = getBootTime() catch return false;
|
||||
|
||||
const boot_time_ns = boot_time * std.time.ns_per_s;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user