Commit 3da2d5c1 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Gracefully handle files with names that break csv.reader

* If encountered, sift_drive will abandon looking at all sibling and
* child items related to the problematic one, and continue on after
* reporting the error
parent d511334f
......@@ -88,29 +88,37 @@ class Sifter:
delimiter=',',
quotechar='"'
)
for child in children:
if not hasattr(self, 'ignore_owner'):
if self.account != child['owners.0.emailAddress']:
continue
data = {
'owner': child['owners.0.emailAddress'],
'name': child['title'],
'id': child['id'],
'link': child['alternateLink'],
'parent': '\\'.join(self.parent)
}
if in_private or child['title'].lower() in self.omit_folders:
self.private_files[child['id']] = data
if 'folder' in child['mimeType']:
self.parent.append(child['title'])
self.sift(child['id'], in_private=True)
else:
self.transfer_files[child['id']] = data
if 'folder' in child['mimeType']:
self.parent.append(child['title'])
self.sift(child['id'], in_private=False)
try:
for child in children:
if not hasattr(self, 'ignore_owner'):
if self.account != child['owners.0.emailAddress']:
continue
data = {
'owner': child['owners.0.emailAddress'],
'name': child['title'],
'id': child['id'],
'link': child['alternateLink'],
'parent': '\\'.join(self.parent)
}
_title = child['title'].lower()
if in_private or _title in self.omit_folders:
self.private_files[child['id']] = data
if 'folder' in child['mimeType']:
self.parent.append(child['title'])
self.sift(child['id'], in_private=True)
else:
self.transfer_files[child['id']] = data
if 'folder' in child['mimeType']:
self.parent.append(child['title'])
self.sift(child['id'], in_private=False)
except csv.Error:
self.logger.warning(
'Failed reading files in {}.'
'Check for bad file title(s)?'.format(self.parent),
extra={'entity': self.account}
)
self.parent.pop()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment