[Git][reproducible-builds/diffoscope][master] Don't traceback when comparing nested directories with non-directories....

Chris Lamb (@lamby) gitlab at salsa.debian.org
Sun Nov 21 18:42:08 UTC 2021



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
78aae03c by Chris Lamb at 2021-11-21T10:41:22-08:00
Don't traceback when comparing nested directories with non-directories. (Closes: reproducible-builds/diffoscope#288)

- - - - -


2 changed files:

- diffoscope/comparators/directory.py
- diffoscope/comparators/utils/compare.py


Changes:

=====================================
diffoscope/comparators/directory.py
=====================================
@@ -253,6 +253,9 @@ class FilesystemDirectory(Directory):
     def compare(self, other, source=None):
         differences = []
 
+        if not isinstance(other, FilesystemDirectory):
+            return differences
+
         # We don't need to recurse into subdirectories; DirectoryContainer will
         # find them and do that for us.
         def list_files(path):


=====================================
diffoscope/comparators/utils/compare.py
=====================================
@@ -118,8 +118,10 @@ def compare_files(file1, file2, source=None, diff_content_only=False):
         file1.other_file = file2
     elif isinstance(file2, MissingFile):
         file2.other_file = file1
-    elif (file1.__class__.__name__ != file2.__class__.__name__) and (
-        file1.as_container is None or file2.as_container is None
+    elif (
+        (file1.__class__.__name__ != file2.__class__.__name__)
+        and (file1.as_container is None or file2.as_container is None)
+        and (not file1.is_directory() and not file2.is_directory())
     ):
         return file1.compare_bytes(file2, source)
     with profile("compare_files (cumulative)", file1):



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/78aae03c4023dc3f2880e5d713a5278a30743995

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/78aae03c4023dc3f2880e5d713a5278a30743995
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20211121/9af94838/attachment.htm>


More information about the rb-commits mailing list