diff --git a/package/yast2-snapper.changes b/package/yast2-snapper.changes index 26e28f8..b806ab9 100644 --- a/package/yast2-snapper.changes +++ b/package/yast2-snapper.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue May 06 16:23:35 CEST 2014 - aschnell@suse.de + +- improved error message on systems with no snapper configs + (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..75d1c88 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 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 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