Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Repository#refresh method (related to bsc #1215884) #1296

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions library/packages/src/lib/y2packager/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,29 @@ def delete!
true
end

# Refresh the repository metadata on disk.
#
# If the repository is loaded in memory you need to reload the repositories
# again to activate the changes.
#
# During refresh the progress callbacks might be executed.
#
# @param force [Boolean] Force refreshing the data unconditionally.
# Disabled by default, libzypp checks the metadata time
# stamp and skips refresh if the repository has been refreshed not long ago.
# See the "repo.refresh.delay" option in /etc/zypp/zypp.conf file.
# @return [Boolean] true on success, false otherwise
#
# @see Yast::Pkg.SourceRefreshNow
# @see Yast::Pkg.SourceForceRefreshNow
def refresh(force: false)
if force
Yast::Pkg.SourceForceRefreshNow(repo_id)
else
Yast::Pkg.SourceRefreshNow(repo_id)
end
end

# Change the repository URL
#
# The URL will be changed only in memory. Calling to
Expand Down
17 changes: 17 additions & 0 deletions library/packages/test/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,23 @@
end
end

describe "#refresh" do
it "runs the refresh only when needed if called without parameters" do
expect(Yast::Pkg).to receive(:SourceRefreshNow).with(repo.repo_id)
repo.refresh
end

it "runs the refresh only when needed if the force parameter is false" do
expect(Yast::Pkg).to receive(:SourceRefreshNow).with(repo.repo_id)
repo.refresh(force: false)
end

it "always runs the refresh if the force parameter is true" do
expect(Yast::Pkg).to receive(:SourceForceRefreshNow).with(repo.repo_id)
repo.refresh(force: true)
end
end

describe "#products" do
let(:products_data) { [product] }
let(:product) do
Expand Down
6 changes: 6 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 1 08:35:38 UTC 2023 - Ladislav Slezák <lslezak@suse.com>

- Added Repository#refresh method (related to bsc #1215884)
mvidner marked this conversation as resolved.
Show resolved Hide resolved
- 5.0.3

-------------------------------------------------------------------
Wed Oct 25 11:16:21 UTC 2023 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 5.0.2
Version: 5.0.3

Release: 0
Summary: YaST2 Main Package
Expand Down
Loading