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,6 +88,7 @@ class Sifter: ...@@ -88,6 +88,7 @@ class Sifter:
delimiter=',', delimiter=',',
quotechar='"' quotechar='"'
) )
try:
for child in children: for child in children:
if not hasattr(self, 'ignore_owner'): if not hasattr(self, 'ignore_owner'):
if self.account != child['owners.0.emailAddress']: if self.account != child['owners.0.emailAddress']:
...@@ -101,7 +102,8 @@ class Sifter: ...@@ -101,7 +102,8 @@ class Sifter:
'parent': '\\'.join(self.parent) 'parent': '\\'.join(self.parent)
} }
if in_private or child['title'].lower() in self.omit_folders: _title = child['title'].lower()
if in_private or _title in self.omit_folders:
self.private_files[child['id']] = data self.private_files[child['id']] = data
if 'folder' in child['mimeType']: if 'folder' in child['mimeType']:
self.parent.append(child['title']) self.parent.append(child['title'])
...@@ -111,6 +113,12 @@ class Sifter: ...@@ -111,6 +113,12 @@ class Sifter:
if 'folder' in child['mimeType']: if 'folder' in child['mimeType']:
self.parent.append(child['title']) self.parent.append(child['title'])
self.sift(child['id'], in_private=False) 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() 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