From a3503b42bc732b47cbf4cbc20e45bded976bfa00 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Tue, 6 May 2014 16:26:54 +0200 Subject: [PATCH 1/2] - improved error messge (bnc#876535) --- package/yast2-snapper.changes | 6 ++++++ package/yast2-snapper.spec | 2 +- src/modules/Snapper.rb | 38 +++++++++++++++++++++------------ testsuite/tests/ReadConfigs.out | 13 ++++++----- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/package/yast2-snapper.changes b/package/yast2-snapper.changes index 26e28f8..bcdb96a 100644 --- a/package/yast2-snapper.changes +++ b/package/yast2-snapper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue May 06 16:23:35 CEST 2014 - aschnell@suse.de + +- improved error messge (bnc#876535) +- 3.1.2 + ------------------------------------------------------------------- Wed Nov 06 09:54:33 CET 2013 - aschnell@suse.de diff --git a/package/yast2-snapper.spec b/package/yast2-snapper.spec index 537f148..df2a94d 100644 --- a/package/yast2-snapper.spec +++ b/package/yast2-snapper.spec @@ -17,7 +17,7 @@ Name: yast2-snapper -Version: 3.1.1 +Version: 3.1.2 Release: 0 Group: System/YaST diff --git a/src/modules/Snapper.rb b/src/modules/Snapper.rb index 784f6ac..8e98411 100644 --- a/src/modules/Snapper.rb +++ b/src/modules/Snapper.rb @@ -53,9 +53,10 @@ def main @selected_snapshot_index = 0 # list of configurations - @configs = ["root"] + @configs = [] + + @current_config = "" - @current_config = "root" end # Return map of files modified between given snapshots @@ -196,6 +197,7 @@ def ReadSnapshots true end + def LastSnapperErrorMap Convert.to_map(SCR.Read(path(".snapper.error"))) end @@ -207,18 +209,19 @@ def ReadConfigs :from => "any", :to => "list " ) - if @configs == nil - # error popup - Report.Error(_("File /etc/sysconfig/snapper is not available.")) - @configs = ["root"] + + if @configs == nil || @configs.empty? + return false end - if !Builtins.contains(@configs, "root") && - Ops.greater_than(Builtins.size(@configs), 0) - @current_config = Ops.get(@configs, 0, "root") + + if @configs.include?("root") + @current_config = "root" + else + @current_config = @configs[0] end - deep_copy(@configs) - end + return true + end # Initialize snapper agent @@ -246,9 +249,10 @@ def InitializeSnapper(config) ) ) end - init + return init end + # Delete existing snapshot # Return true on success def DeleteSnapshot(args) @@ -343,7 +347,13 @@ def Read Progress.NextStage - ReadConfigs() + if !ReadConfigs() + # error popup + Report.Error(_("No snapper configs exist. You have to create one or more +configs to use yast2-snapper. The snapper command line +tool can be used to create configs.")) + return false + end return false if !InitializeSnapper(@current_config) @@ -493,7 +503,7 @@ def RestoreFiles(snapshot_num, files) publish :function => :GetFileModification, :type => "map (string, integer, integer)" publish :function => :ReadSnapshots, :type => "boolean ()" publish :function => :LastSnapperErrorMap, :type => "map ()" - publish :function => :ReadConfigs, :type => "list ()" + publish :function => :ReadConfigs, :type => "boolean ()" publish :function => :InitializeSnapper, :type => "boolean (string)" publish :function => :DeleteSnapshot, :type => "boolean (map)" publish :function => :ModifySnapshot, :type => "boolean (map)" diff --git a/testsuite/tests/ReadConfigs.out b/testsuite/tests/ReadConfigs.out index 4d03d8d..9dfe1e8 100644 --- a/testsuite/tests/ReadConfigs.out +++ b/testsuite/tests/ReadConfigs.out @@ -1,13 +1,12 @@ Read .snapper.configs [] -Return [] -Return root +Return false +Return Read .snapper.configs nil -Log File /etc/sysconfig/snapper is not available. -Return ["root"] -Return root +Return false +Return Read .snapper.configs ["opt", "var", "root"] -Return ["opt", "var", "root"] +Return true Return root Read .snapper.configs ["opt", "var"] -Return ["opt", "var"] +Return true Return opt From 0a0d69aa62c4a5a508c8db8235081c90adf69a8a Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Tue, 6 May 2014 17:27:00 +0200 Subject: [PATCH 2/2] - longer text --- package/yast2-snapper.changes | 3 ++- src/modules/Snapper.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package/yast2-snapper.changes b/package/yast2-snapper.changes index bcdb96a..b806ab9 100644 --- a/package/yast2-snapper.changes +++ b/package/yast2-snapper.changes @@ -1,7 +1,8 @@ ------------------------------------------------------------------- Tue May 06 16:23:35 CEST 2014 - aschnell@suse.de -- improved error messge (bnc#876535) +- improved error message on systems with no snapper configs + (bnc#876535) - 3.1.2 ------------------------------------------------------------------- diff --git a/src/modules/Snapper.rb b/src/modules/Snapper.rb index 8e98411..75d1c88 100644 --- a/src/modules/Snapper.rb +++ b/src/modules/Snapper.rb @@ -349,9 +349,9 @@ def Read if !ReadConfigs() # error popup - Report.Error(_("No snapper configs exist. You have to create one or more -configs to use yast2-snapper. The snapper command line -tool can be used to create configs.")) + Report.Error(_("No snapper configurations exist. You have to create one or more +configurations to use yast2-snapper. The snapper command line +tool can be used to create configurations.")) return false end