From b35eb896f5c0eee6cbb2c4d7e266d3f2dd49d99f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 16 Jun 2024 02:31:46 +0200 Subject: [PATCH] survive missing mimetypes --- fcp3/sitemgr.py | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/fcp3/sitemgr.py b/fcp3/sitemgr.py index 6972feb..4cf86f7 100644 --- a/fcp3/sitemgr.py +++ b/fcp3/sitemgr.py @@ -1603,12 +1603,19 @@ def fileMsgLines(n, rec): sizebytes = os.path.getsize(rec['path']) rec['sizebytes'] = sizebytes rec['dda'] = True - return [ - "Files.%d.Name=%s" % (n, rec['name']), - "Files.%d.UploadFrom=disk" % n, - "Files.%d.Filename=%s" % (n, rec['path']), - "Files.%d.Metadata.ContentType=%s" % (n, rec['mimetype']), - ] + if rec.get('mimetype', None): + return [ + "Files.%d.Name=%s" % (n, rec['name']), + "Files.%d.UploadFrom=disk" % n, + "Files.%d.Filename=%s" % (n, rec['path']), + "Files.%d.Metadata.ContentType=%s" % (n, rec['mimetype']), + ] + else: + return [ + "Files.%d.Name=%s" % (n, rec['name']), + "Files.%d.UploadFrom=disk" % n, + "Files.%d.Filename=%s" % (n, rec['path']), + ] else: if rec['name'] in self.generatedTextData: data = self.generatedTextData[rec['name']].encode("utf-8") @@ -1617,12 +1624,19 @@ def fileMsgLines(n, rec): datatoappend.append(data) # update the sizebytes from the data actually read here. rec['sizebytes'] = len(data) - return [ - "Files.%d.Name=%s" % (n, rec['name']), - "Files.%d.UploadFrom=direct" % n, - "Files.%d.DataLength=%s" % (n, rec['sizebytes']), - "Files.%d.Metadata.ContentType=%s" % (n, rec['mimetype']), - ] + if rec.get('mimetype', None): + return [ + "Files.%d.Name=%s" % (n, rec['name']), + "Files.%d.UploadFrom=direct" % n, + "Files.%d.DataLength=%s" % (n, rec['sizebytes']), + "Files.%d.Metadata.ContentType=%s" % (n, rec['mimetype']), + ] + else: + return [ + "Files.%d.Name=%s" % (n, rec['name']), + "Files.%d.UploadFrom=direct" % n, + "Files.%d.DataLength=%s" % (n, rec['sizebytes']), + ] # start with index.html's uri and the sitemap