Skip to content

Commit

Permalink
Merge pull request #29 from aschnell/master
Browse files Browse the repository at this point in the history
- improved error messge (bnc#876535)
  • Loading branch information
aschnell committed May 7, 2014
2 parents 1c8e5af + 0a0d69a commit 369224d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
7 changes: 7 additions & 0 deletions 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

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-snapper.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-snapper
Version: 3.1.1
Version: 3.1.2
Release: 0
Group: System/YaST

Expand Down
38 changes: 24 additions & 14 deletions src/modules/Snapper.rb
Expand Up @@ -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
Expand Down Expand Up @@ -196,6 +197,7 @@ def ReadSnapshots
true
end


def LastSnapperErrorMap
Convert.to_map(SCR.Read(path(".snapper.error")))
end
Expand All @@ -207,18 +209,19 @@ def ReadConfigs
:from => "any",
:to => "list <string>"
)
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
Expand Down Expand Up @@ -246,9 +249,10 @@ def InitializeSnapper(config)
)
)
end
init
return init
end


# Delete existing snapshot
# Return true on success
def DeleteSnapshot(args)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 <string> ()"
publish :function => :ReadConfigs, :type => "boolean ()"
publish :function => :InitializeSnapper, :type => "boolean (string)"
publish :function => :DeleteSnapshot, :type => "boolean (map)"
publish :function => :ModifySnapshot, :type => "boolean (map)"
Expand Down
13 changes: 6 additions & 7 deletions 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

0 comments on commit 369224d

Please sign in to comment.