[diffoscope] 01/01: Remove incorrect naive optimisation with os.makedirs()

Ximin Luo infinity0 at debian.org
Mon Feb 13 14:55:17 CET 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 3a7f233caf157cc7ab488cb9629e149b2bbe39b2
Author: Ximin Luo <infinity0 at debian.org>
Date:   Mon Feb 13 14:54:15 2017 +0100

    Remove incorrect naive optimisation with os.makedirs()
    
    - it probably won't make a difference given everything else that needs to be
      done in the same loop iteration
---
 diffoscope/comparators/utils/libarchive.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/diffoscope/comparators/utils/libarchive.py b/diffoscope/comparators/utils/libarchive.py
index 4206efd..b8ba582 100644
--- a/diffoscope/comparators/utils/libarchive.py
+++ b/diffoscope/comparators/utils/libarchive.py
@@ -217,19 +217,16 @@ class LibarchiveContainer(Archive):
                 if any_excluded(entry.pathname):
                     continue
 
+                # Keep directory sizes small. could be improved but should be
+                # good enough for "ordinary" large archives.
+                dst = os.path.join(tmpdir, str(idx // 4096), str(idx % 4096))
                 # Maintain a mapping of archive path to the extracted path,
                 # avoiding the need to sanitise filenames.
-                not_first = idx % 4096
-                # keep directory sizes small. could be improved but should be
-                # good enough for "ordinary" large archives.
-                basename = os.path.join(str(idx // 4096), str(not_first))
-                dst = os.path.join(tmpdir, basename)
                 self._members[entry.pathname] = dst
 
                 logger.debug("Extracting %s to %s", entry.pathname, dst)
 
-                if not not_first:
-                    os.makedirs(os.path.dirname(dst), exist_ok=True)
+                os.makedirs(os.path.dirname(dst), exist_ok=True)
                 with open(dst, 'wb') as f:
                     for block in entry.get_blocks():
                         f.write(block)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list