Merge pull request #449 from vext01/unicode_listing_fix

Don't crash if a filename contains invalid unicode.
This commit is contained in:
Min RK 2015-09-23 12:21:32 +02:00
commit 9b514b1406

View File

@ -245,7 +245,12 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
model['content'] = contents = []
os_dir = self._get_os_path(path)
for name in os.listdir(os_dir):
os_path = os.path.join(os_dir, name)
try:
os_path = os.path.join(os_dir, name)
except UnicodeDecodeError as e:
self.log.warn(
"failed to decode filename '%s': %s", name, e)
continue
# skip over broken symlinks in listing
if not os.path.exists(os_path):
self.log.warn("%s doesn't exist", os_path)