From 042bd36c25206ff45e305d094028b6482a4c4074 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 9 Apr 2020 17:48:47 -0700 Subject: bugfix: handle missing file mimetypes --- bin/deliver_file2disk.py | 2 +- fatcat_covid19/common.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/deliver_file2disk.py b/bin/deliver_file2disk.py index 49e0c73..e5f13c0 100755 --- a/bin/deliver_file2disk.py +++ b/bin/deliver_file2disk.py @@ -123,7 +123,7 @@ class DeliverFatcatDisk: """ good = [] for f in files: - if f['mimetype'] and not 'pdf' in f['mimetype'].lower(): + if f.get('mimetype') and not 'pdf' in f['mimetype'].lower(): continue for url in f['urls']: if 'archive.org/' in url['url']: diff --git a/fatcat_covid19/common.py b/fatcat_covid19/common.py index 97bc675..7b88344 100644 --- a/fatcat_covid19/common.py +++ b/fatcat_covid19/common.py @@ -80,7 +80,7 @@ def find_local_file(files, base_dir="."): If found, returns the file entity; the path can be determined from the sha1hex field. """ for f in files: - if f['mimetype'] and not 'pdf' in f['mimetype'].lower(): + if f.get('mimetype') and not 'pdf' in f['mimetype'].lower(): continue pdf_path = blob_path(f['sha1'], directory="pdf/", file_suffix=".pdf", base_dir=base_dir) if os.path.isfile(pdf_path): -- cgit v1.2.3