[yast-commit] r64143 - in /trunk/snapper: agent-snapper/src/SnapperAgent.cc src/Snapper.ycp
Author: jsuchome Date: Mon May 30 14:51:39 2011 New Revision: 64143 URL: http://svn.opensuse.org/viewcvs/yast?rev=64143&view=rev Log: ask snapper library for snapshot paths Modified: trunk/snapper/agent-snapper/src/SnapperAgent.cc trunk/snapper/src/Snapper.ycp Modified: trunk/snapper/agent-snapper/src/SnapperAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/agent-snapper/src/Snapper... ============================================================================== --- trunk/snapper/agent-snapper/src/SnapperAgent.cc (original) +++ trunk/snapper/agent-snapper/src/SnapperAgent.cc Mon May 30 14:51:39 2011 @@ -148,7 +148,7 @@ if (path->length() == 1) { /** - * error: Read (.snapper.error) -> returns last error message + * Read (.snapper.error) -> returns last error message */ if (PC(0) == "error") { YCPMap retmap; @@ -156,6 +156,21 @@ return retmap; } /** + * Read (.snapper.path, $[ "num" : num]) -> returns the path to directory with given snapshot + */ + if (PC(0) == "path") { + unsigned int num = getIntValue (argmap, "num", 0); + const Snapshots& snapshots = sh->getSnapshots(); + Snapshots::const_iterator snap = snapshots.find(num); + if (snap == snapshots.end()) + { + y2error ("snapshot '%d' not found", num); + return ret; + } + return YCPString (snap->snapshotDir()); + } + + /** * Read(.snapper.snapshots) -> return list of snapshot description maps */ if (PC(0) == "snapshots") { Modified: trunk/snapper/src/Snapper.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/snapper/src/Snapper.ycp?rev=64143... ============================================================================== --- trunk/snapper/src/Snapper.ycp (original) +++ trunk/snapper/src/Snapper.ycp Mon May 30 14:51:39 2011 @@ -43,8 +43,6 @@ // global list of all snapshot global list<map> snapshots = []; -global string snapshots_path = "/snapshots"; - global map selected_snapshot = $[]; // mapping of snapshot number to index in snapshots list @@ -70,15 +68,28 @@ } /** + * Return the path to given snapshot + */ +global string GetSnapshotPath (integer snapshot_num) { + string ret = (string) SCR::Read (.snapper.path, $[ "num" : snapshot_num ]); + if (ret == nil) + { + ret = ""; + // popup error + Report::Error (sformat (_("Snapshot '%1' was not found."), snapshot_num)); + } + return ret; +} + +/** * Describe what was done with given file between given snapshots * - when new is 0, meaning is 'current system' */ global map GetFileModification (string file, integer old, integer new) { map ret = $[]; - - string file1 = sformat ("%1/%2/snapshot%3", snapshots_path, old, file); - string file2 = sformat ("%1/%2/snapshot%3", snapshots_path, new, file); + string file1 = sformat ("%1%2", GetSnapshotPath (old), file); + string file2 = sformat ("%1%2", GetSnapshotPath (new), file); if (new == 0) file2 = file; @@ -270,7 +281,7 @@ UI::ChangeWidget (`id (`progress ), `Value, progress); - string orig = sformat ("%1/%2/snapshot", snapshots_path, snapshot_num) + file; + string orig = GetSnapshotPath (snapshot_num) + file; string dir = substring (file, 0, findlastof (file, "/")); if (!FileUtils::Exists (orig)) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jsuchome@svn2.opensuse.org