Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions service/lib/agama/storage/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ def on_calculate(&block)
#
# @return [Array<Y2Storage::Device>]
def available_devices
disk_analyzer.candidate_disks
disk_analyzer&.candidate_disks || []
end

# Calculates a new proposal.
#
# @param settings [Agamal::Storage::ProposalSettings] settings to calculate the proposal.
# @return [Boolean] whether the proposal was correctly calculated.
def calculate(settings)
return false unless storage_manager.probed?

select_target_device(settings) if missing_target_device?(settings)

calculate_proposal(settings)
Expand Down Expand Up @@ -170,15 +172,19 @@ def calculate_proposal(settings)
storage_manager.proposal = proposal
end

# @return [Y2Storage::DiskAnalyzer]
# @return [Y2Storage::DiskAnalyzer, nil] nil if the system is not probed yet.
def disk_analyzer
return nil unless storage_manager.probed?

storage_manager.probed_disk_analyzer
end

# Devicegraph representing the system
#
# @return [Y2Storage::Devicegraph]
# @return [Y2Storage::Devicegraph, nil] nil if the system is not probed yet.
def probed_devicegraph
return nil unless storage_manager.probed?

storage_manager.probed
end

Expand Down
5 changes: 5 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu May 16 15:36:16 UTC 2024 - José Iván López González <jlopez@suse.com>

- Do not probe devices implictly (gh#openSUSE/agama#1226).

-------------------------------------------------------------------
Wed May 15 12:52:42 UTC 2024 - José Iván López González <jlopez@suse.com>

Expand Down
28 changes: 28 additions & 0 deletions service/test/agama/storage/proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,34 @@
end
end
end

context "if the system has not been probed yet" do
before do
allow(Y2Storage::StorageManager.instance).to receive(:probed?).and_return(false)
end

it "does not calculate a proposal" do
subject.calculate(achievable_settings)
expect(Y2Storage::StorageManager.instance.proposal).to be_nil
end

it "does not run the callbacks" do
callback1 = proc {}
callback2 = proc {}

subject.on_calculate(&callback1)
subject.on_calculate(&callback2)

expect(callback1).to_not receive(:call)
expect(callback2).to_not receive(:call)

subject.calculate(achievable_settings)
end

it "returns false" do
expect(subject.calculate(achievable_settings)).to eq(false)
end
end
end

describe "#settings" do
Expand Down