Skip to content

Commit

Permalink
close file after testing for existence
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdonp committed Jul 10, 2019
1 parent a7b89b0 commit 8bf6280
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/db/file.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ pub fn init(allocator: *Allocator) !void {
pub fn has(namespace: []const u8, key: []const u8, allocator: *Allocator) bool {
var keypath = std.fmt.allocPrint(allocator, "{}/{}/{}", cache_dir, namespace, key) catch unreachable;
var found = false;
if (std.fs.File.openRead(keypath)) |*file| {
// zig stat() not ready
if (std.fs.File.openRead(keypath)) |file| {
std.fs.File.close(file);
found = true;
} else |err| {
warn("dbfile did not find {}\n", keypath);
Expand Down
3 changes: 1 addition & 2 deletions src/gui/gtk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ pub fn update_column_toots(column: *Column) void {
}
c.gtk_widget_show(column_toot_zone);

const countBuf = allocator.alloc(u8, 256) catch unreachable;
const countStr = std.fmt.bufPrint(countBuf, "{} toots", column.main.toots.count()) catch unreachable;
const countStr = std.fmt.allocPrint(allocator, "{} toots", column.main.toots.count()) catch unreachable;
const cCountStr = util.sliceToCstr(allocator, countStr);
c.gtk_label_set_text(@ptrCast([*c]c.GtkLabel, column_footer_count_label), cCountStr);
}
Expand Down

0 comments on commit 8bf6280

Please sign in to comment.