Skip to content

Commit c2a7c9a

Browse files
dyoung522claude
andcommitted
fix: match find_info by name AND author to prevent duplicates
The find_info method was only matching by name, which was inconsistent with the rest of the codebase (info_array deduplication, find_by_type). This caused incorrect deletion logic when mods/tools had the same name but different authors, leading to duplicate entries in the database. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d6ce619 commit c2a7c9a

6 files changed

Lines changed: 50 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## History (reverse chronological order)
66

7+
### v2.5.3 - 2026-03-04
8+
9+
- Fix `find_info` to match by both name AND author, not just name
10+
- Previously, mods/tools with the same name but different authors could cause incorrect deletion logic
11+
- Now consistent with `info_array` deduplication and `find_by_type` lookups
12+
713
### v2.5.2 - 2026-02-09
814

915
- Fix duplicate entries created during sync operations

lib/icarus/mod/tools/sync/mods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def find(modinfo)
3636
end
3737

3838
def find_info(modinfo)
39-
@info_array.find { |mod| mod.name == modinfo.name }
39+
@info_array.find { |mod| mod.name == modinfo.name && mod.author == modinfo.author }
4040
end
4141

4242
def update(modinfo)

lib/icarus/mod/tools/sync/tools.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def find(toolinfo)
3838
end
3939

4040
def find_info(toolinfo)
41-
@info_array.find { |tool| tool.name == toolinfo.name }
41+
@info_array.find { |tool| tool.name == toolinfo.name && tool.author == toolinfo.author }
4242
end
4343

4444
def update(toolinfo)

lib/icarus/mod/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Icarus
44
module Mod
5-
VERSION = "2.5.2"
5+
VERSION = "2.5.3"
66
end
77
end

spec/icarus/mod/tools/sync/mods_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,30 @@
9595
end
9696
end
9797

98-
describe "#find_modinfo" do
98+
describe "#find_info" do
9999
it "returns a Modinfo object" do
100100
expect(modsync.find_info(modinfo)).to be_a(Icarus::Mod::Tools::Modinfo)
101101
end
102+
103+
context "when mods have the same name but different authors" do
104+
let(:mod_author1) { Icarus::Mod::Tools::Modinfo.new({ name: "SharedName", author: "Author1", description: "Test" }) }
105+
let(:mod_author2) { Icarus::Mod::Tools::Modinfo.new({ name: "SharedName", author: "Author2", description: "Test" }) }
106+
let(:search_for_author2) { Icarus::Mod::Tools::Modinfo.new({ name: "SharedName", author: "Author2", description: "Test" }) }
107+
108+
before do
109+
modsync.instance_variable_set(:@info_array, [mod_author1, mod_author2])
110+
end
111+
112+
it "matches by both name AND author, not just name" do
113+
result = modsync.find_info(search_for_author2)
114+
expect(result.author).to eq("Author2")
115+
end
116+
117+
it "returns nil when author does not match" do
118+
nonexistent = Icarus::Mod::Tools::Modinfo.new({ name: "SharedName", author: "Author3", description: "Test" })
119+
expect(modsync.find_info(nonexistent)).to be_nil
120+
end
121+
end
102122
end
103123

104124
describe "#update" do

spec/icarus/mod/tools/sync/tools_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@
9999
it "returns a Toolinfo object" do
100100
expect(toolsync.find_info(toolinfo)).to be_a(Icarus::Mod::Tools::Toolinfo)
101101
end
102+
103+
context "when tools have the same name but different authors" do
104+
let(:tool_author1) { Icarus::Mod::Tools::Toolinfo.new({ name: "SharedName", author: "Author1", description: "Test" }) }
105+
let(:tool_author2) { Icarus::Mod::Tools::Toolinfo.new({ name: "SharedName", author: "Author2", description: "Test" }) }
106+
let(:search_for_author2) { Icarus::Mod::Tools::Toolinfo.new({ name: "SharedName", author: "Author2", description: "Test" }) }
107+
108+
before do
109+
toolsync.instance_variable_set(:@info_array, [tool_author1, tool_author2])
110+
end
111+
112+
it "matches by both name AND author, not just name" do
113+
result = toolsync.find_info(search_for_author2)
114+
expect(result.author).to eq("Author2")
115+
end
116+
117+
it "returns nil when author does not match" do
118+
nonexistent = Icarus::Mod::Tools::Toolinfo.new({ name: "SharedName", author: "Author3", description: "Test" })
119+
expect(toolsync.find_info(nonexistent)).to be_nil
120+
end
121+
end
102122
end
103123

104124
describe "#update" do

0 commit comments

Comments
 (0)