From 540cc7e3e57b3c835e3a6995d3e7d04656e029d3 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Fri, 28 Aug 2026 02:49:29 +0300 Subject: [PATCH 1/2] Direct commit and abort to their own store transaction --- lib/pstore.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pstore.rb b/lib/pstore.rb index e730be2..2a9dd39 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -527,7 +527,7 @@ def path def commit in_transaction @abort = false - throw :pstore_abort_transaction + throw self end # Exits the current transaction block, discarding any changes @@ -538,7 +538,7 @@ def commit def abort in_transaction @abort = true - throw :pstore_abort_transaction + throw self end # Opens a transaction block for the store. @@ -570,7 +570,7 @@ def transaction(read_only = false) # :yields: pstore begin @table, checksum, original_data_size = load_data(file, read_only) - catch(:pstore_abort_transaction) do + catch(self) do value = yield(self) end @@ -583,7 +583,7 @@ def transaction(read_only = false) # :yields: pstore else # This can only occur if read_only == true. @table = {} - catch(:pstore_abort_transaction) do + catch(self) do value = yield(self) end end From 331bed3577bf93661916a101582590b5db816a17 Mon Sep 17 00:00:00 2001 From: Oskar Eichler <62393985+OskarEichler@users.noreply.github.com> Date: Fri, 28 Aug 2026 14:59:59 +0300 Subject: [PATCH 2/2] test: cover PStore regression --- test/test_pstore.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_pstore.rb b/test/test_pstore.rb index 4a65e4f..a5d27ff 100644 --- a/test/test_pstore.rb +++ b/test/test_pstore.rb @@ -190,4 +190,22 @@ def clear_store def second_file File.join(Dir.tmpdir, "pstore.tmp2.#{Process.pid}") end + def test_commit_targets_the_owning_store + inner = PStore.new(second_file) + @pstore.transaction do + @pstore[:outer] = true + inner.transaction do + inner[:inner] = true + @pstore.commit + flunk("outer commit should exit its own transaction") + end + flunk("outer commit should exit its own transaction") + end + + assert_equal(true, @pstore.transaction(true) { @pstore[:outer] }) + assert_nil(inner.transaction(true) { inner[:inner] }) + ensure + File.unlink(second_file) rescue nil + end + end