[Git][reproducible-builds/diffoscope][master] 2 commits: Don't crash if we encounter an .rdb file without an equivalent .rdx file. (Closes: Debian:#1066991)
Chris Lamb (@lamby)
gitlab at salsa.debian.org
Wed Mar 20 11:01:31 UTC 2024
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
1dc8c79e by Chris Lamb at 2024-03-20T10:55:08+00:00
Don't crash if we encounter an .rdb file without an equivalent .rdx file. (Closes: Debian:#1066991)
- - - - -
28165345 by Chris Lamb at 2024-03-20T10:59:12+00:00
Don't identify Redis database dumps (etc.) as GNU R database files based simply on their filename. (Re: Debian:#1066991)
- - - - -
1 changed file:
- diffoscope/comparators/rdata.py
Changes:
=====================================
diffoscope/comparators/rdata.py
=====================================
@@ -96,12 +96,20 @@ def get_module_path_for_rdb(rdb, temp_dir, module_name):
rdx_name = "{}.rdx".format(os.path.splitext(rdb.name)[0])
# Query the container for the full path (eg. `./path/to/foo.rdx`)...
- rdx = rdb.container.get_member(rdx_name)
+ try:
+ rdx = rdb.container.get_member(rdx_name)
+ except KeyError:
+ # There is no guarantee that the equivalent .rdx file exists.
+ # (see Debian:#1066991)
+ return None
if not os.path.exists(rdx.path):
# ... falling back to looking in the same directory for when
# comparing two .rdb files directly
- rdx = rdb.container.get_member(os.path.basename(rdx_name))
+ try:
+ rdx = rdb.container.get_member(os.path.basename(rdx_name))
+ except KeyError:
+ return None
if not os.path.exists(rdx.path):
# Corresponding .rdx does not exist
@@ -161,6 +169,14 @@ class RdbFile(File):
DESCRIPTION = "GNU R database files (.rdb)"
FILE_EXTENSION_SUFFIX = {".rdb"}
+ @classmethod
+ def recognizes(cls, file):
+ # file(1) does not yet support identifying R database files, so we
+ # match on "data" AND the filename ends with .rdb (via
+ # FILE_EXTENSION_SUFFIX above) to avoid matching, say, Redis database
+ # dumps (dump.rdb).
+ return file.magic_file_type == "data"
+
def compare_details(self, other, source=None):
with get_temporary_directory(suffix="rdb") as tmpdir:
a = get_module_path_for_rdb(self, tmpdir, "a")
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/fc8fba688f61e4603226abc8e4ff92a681ee4312...28165345e6332cb5c5687e850a1e10b4d8b4b6a4
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/fc8fba688f61e4603226abc8e4ff92a681ee4312...28165345e6332cb5c5687e850a1e10b4d8b4b6a4
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/20240320/be585cf4/attachment.htm>
More information about the rb-commits
mailing list