os.listdir returns str for non-latin filename, use unicode cast in path name to avoid this. Related to gh-issue #163.

This commit is contained in:
Roberto Rosario
2015-07-08 02:02:24 -04:00
parent 90be5145c0
commit 4c25314772

View File

@@ -344,10 +344,11 @@ class WatchFolderSource(IntervalBaseModel):
folder_path = models.CharField(max_length=255, verbose_name=_('Folder path'), help_text=_('Server side filesystem path.'))
def check_source(self):
for file_name in os.listdir(self.folder_path):
# Force self.folder_path to unicode to avoid os.listdir returning
# str for non-latin filenames, gh-issue #163
for file_name in os.listdir(unicode(self.folder_path)):
full_path = os.path.join(self.folder_path, file_name)
if os.path.isfile(full_path):
with File(file=open(full_path, mode='rb')) as file_object:
self.upload_document(file_object, label=file_name, expand=(self.uncompress == SOURCE_UNCOMPRESS_CHOICE_Y))
os.unlink(full_path)