Skip to content

Commit

Permalink
Display a global progress for self update
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Aug 22, 2016
1 parent 80b0906 commit 5fbe297
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
35 changes: 35 additions & 0 deletions src/lib/installation/clients/inst_update_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ def main
# shortcut - already updated
return :next if installer_updated?

# open a new wizard dialog with title on the top
# (the default dialog with title on the left looks ugly with the
# Progress dialog)
Yast::Wizard.CreateDialog
@wizard_open = true

Yast::Progress.New(
# TRANSLATORS: dialog title
_("Updating the Installer..."),
# TRANSLATORS: progress title
_("Updating the Installer..."),
# max is 100%
100,
# stages
[
# TRANSLATORS: progress label
_("Add Update Repository"),
_("Download the Packages"),
_("Restart")
],
# steps
[],
# help text
""
)

# mark the first stage active
Yast::Progress.NextStage

# initialize packager, we need to load the base product name
# to properly obtain the update URL from the registration server
return :abort unless initialize_packager
Expand All @@ -71,10 +100,16 @@ def main
if installer_updated
# Indicates that the installer was updated.
::FileUtils.touch(update_flag_file)
Yast::Progress.NextStage
Installation.restart!
else
:next
end
ensure
if @wizard_open
Yast::Progress.Finish
Yast::Wizard.CloseDialog
end
end

# Tries to update the installer
Expand Down
35 changes: 3 additions & 32 deletions src/lib/installation/update_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,13 @@ def fetch(path = Pathname("/download"))
init_progress

packages.each_with_object(update_files).with_index do |(package, files), index|
update_progress(index)
update_progress(100 * index / packages.size)
files << fetch_package(package, path)
end
rescue PackageNotFound, CouldNotExtractPackage, CouldNotSquashPackage => e
log.error("Could not fetch update: #{e.inspect}. Rolling back.")
remove_update_files
raise CouldNotFetchUpdate
ensure
finish_progress
end

# Remove fetched packages
Expand Down Expand Up @@ -383,30 +381,9 @@ def update_instsys_parts(path, mountpoint)
end
end

# Initialize the progress if it is enabled.
# Initialize the progress
def init_progress
# open a new wizard window for the progress (only when Progress is enabled)
# to not mess the current dialog
Yast::Wizard.CreateDialog if Yast::Progress.status
Yast::Progress.New(
# TRANSLATORS: dialog title
_("Updating..."),
# TRANSLATORS: progress title
_("Downloading Packages..."),
# size
packages.size,
# stages
[
# TRANSLATORS: progress label
_("Downloading the Installer Updates...")
],
# steps
[],
# help text
""
)

# mark the first stage active
# mark the next stage active
Yast::Progress.NextStage
end

Expand All @@ -415,11 +392,5 @@ def init_progress
def update_progress(percent)
Yast::Progress.Step(percent)
end

# Close the progress if it is enabled
def finish_progress
Yast::Progress.Finish
Yast::Wizard.CloseDialog if Yast::Progress.status
end
end
end

0 comments on commit 5fbe297

Please sign in to comment.