Commit e0e10c41 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Ignore errors when listing .ar archives. (Closes: Debian:#1085257)

parent 7b46ad67
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -69,8 +69,8 @@ class ArFile(File):
                ArSymbolTableDumper, self.path, other.path
            ),
            Difference.from_text_readers(
                list_libarchive(self.path),
                list_libarchive(other.path),
                list_libarchive(self.path, ignore_errors=True),
                list_libarchive(other.path, ignore_errors=True),
                self.path,
                other.path,
                source="file list",
+8 −0
Original line number Diff line number Diff line
@@ -122,6 +122,14 @@ libarchive.ArchiveEntry.pathname = property(


def list_libarchive(path, ignore_errors=False):
    """
    NB. Despite this method's contents being wrapped entirely in a try/except,
    the use of yield operator means that the setting `ignore_errors` to `True`
    will emit valid entries until there is an error, rather than a) masking all
    entries if there is any error or b) skipping *over* errors to the next
    entry.
    """

    def force_str(val):
        # libarchive ~5 began to return uname and gname as UTF-8 whilst
        # previous versions returned bytes that required decoding.