]> git.lyx.org Git - features.git/commitdiff
lyxpak: Fix the common path prefix calculation.
authorGuy Rutenberg <guyrutenberg@gmail.com>
Fri, 26 Jun 2015 15:35:52 +0000 (18:35 +0300)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 5 Jul 2015 11:33:14 +0000 (13:33 +0200)
The old implementation could fail in some rare cases.

lib/scripts/lyxpak.py

index 9d5add137d74cc4bfa957b109689e338df80ef82..cc1bdfda7b67a6d6a463ca0ad59b51e54de864a2 100755 (executable)
@@ -298,10 +298,9 @@ def main(args):
     # Find the topmost dir common to all files
     if len(incfiles) > 1:
         topdir = os.path.commonprefix(incfiles)
-        # Check whether topdir is valid, as os.path.commonprefix() works on
-        # a character by character basis, rather than on path elements.
-        if not os.path.exists(topdir):
-            topdir = os.path.dirname(topdir) + os.path.sep
+        # As os.path.commonprefix() works on a character by character basis,
+        # rather than on path elements, we need to remove any trailing bytes.
+        topdir = topdir.rpartition(os.path.sep)[0] + os.path.sep
     else:
         topdir = os.path.dirname(incfiles[0]) + os.path.sep