Skip to content

Commit

Permalink
survive missing mimetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Dec 15, 2024
1 parent 94da066 commit b35eb89
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions fcp3/sitemgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit b35eb89

Please sign in to comment.