Skip to main content

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

  • From: Shawn Walker < >
  • To:
  • Cc: Erik Trauschke < >, Edward Pilatowicz < >
  • Subject: [pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files
  • Date: Wed, 04 Jun 2014 10:02:11 -0700

On 06/04/14 09:43, Erik Trauschke wrote:


On 06/ 3/14 04:32 PM, Edward Pilatowicz wrote:
On Tue, Jun 03, 2014 at 03:59:31PM -0700, Erik Trauschke wrote:
This is a small fix for
18877276 first character trimmed from display of salvaged files

This code hasn't changed in a while. The reason this worked until
recently was that image.get_root() would return "//" for the live
image. I think this got fixed with Ed's li alternate path fixes.

The fix below takes care of all sorts of paths, it should also work
if there are double slashes or any other craziness in the path.


Thanks
Erik

---
diff -r 7863650e8a13 src/modules/client/pkgplan.py
--- a/src/modules/client/pkgplan.py    Fri May 30 15:21:07 2014 -0700
+++ b/src/modules/client/pkgplan.py    Tue Jun 03 15:54:10 2014 -0700
@@ -578,8 +578,11 @@

                  assert self._executed
                  spath = self.image.salvage(path)
-                # get just the file path that was salvaged
-                fpath = path[len(self.image.get_root()) + 1:]
+                # get just the file path that was salvaged
+                fpath = path.replace(
+                    os.path.normpath(self.image.get_root()), "", 1)
+                if fpath.startswith("/"):
+                        fpath = fpath[1:]
                  self.image.imageplan.pd._salvaged.append((fpath,
spath))

          def salvage_from(self, local_path, full_destination):

this code assumes that fpath will always be prefixed by the result of
get_root().  if this assumption is ever violated this code will break.
hence, i'd recommend assert()ing this assumption:

     assert fpath.startswith(self.image.get_root())

The problem I have with this is that we are talking mainly about a
display issue here. So instead of having an incorrect display, you want
to terminate the pkg application?

I think it might be better to just check for this and set fpath to path
if the root is missing from path.

That would be my preferred solution.

As Erik notes, since this is for display purposes, we purposefully strip off both the img_root and/or leading '/'.

-Shawn



[pkg-discuss] [review] 18877276 first character trimmed from display of salvaged files

Erik Trauschke 06/03/2014

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

Edward Pilatowicz 06/03/2014

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

Erik Trauschke 06/04/2014

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

Shawn Walker 06/04/2014

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

Shawn Walker 06/04/2014

[pkg-discuss] Re: [review] 18877276 first character trimmed from display of salvaged files

Erik Trauschke 06/04/2014
 
 
Close
loading
Please Confirm
Close