fix: make sure we release self.snapshots_mutex on errors

This commit is contained in:
CJ van den Berg 2026-03-14 18:42:43 +01:00
parent 505b9efeb8
commit 00140fcfe6
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 2 additions and 0 deletions

View file

@ -386,6 +386,7 @@ fn take_snapshot(self: *@This(), allocator: std.mem.Allocator, dir_path: []const
try names.append(allocator, try allocator.dupe(u8, entry.name));
}
self.snapshots_mutex.lock();
errdefer self.snapshots_mutex.unlock();
const gop = try self.snapshots.getOrPut(allocator, dir_path);
if (!gop.found_existing) gop.value_ptr.* = .empty;
var snapshot = gop.value_ptr;