From: Guy Rutenberg Date: Fri, 26 Jun 2015 15:35:52 +0000 (+0300) Subject: lyxpak: Fix the common path prefix calculation. X-Git-Tag: 2.2.0alpha1~474 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ca0ba7c6ad86d598a8db1a47faae130b0ae329b4;p=features.git lyxpak: Fix the common path prefix calculation. The old implementation could fail in some rare cases. --- diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py index 9d5add137d..cc1bdfda7b 100755 --- a/lib/scripts/lyxpak.py +++ b/lib/scripts/lyxpak.py @@ -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