summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/utils.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 2156d4f95..e6bc38237 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -1031,7 +1031,14 @@ def rename_and_simplify_media_name(full_path_name, rename=True):
:param rename: rename file if True (default: True)
:return: new full path name (or old if not changed), modified
"""
- if not os.path.exists(full_path_name) or not os.path.isfile(full_path_name):
+ try:
+ exists = os.path.exists(full_path_name)
+ is_file = os.path.isfile(full_path_name)
+ except UnicodeEncodeError:
+ full_path_name = full_path_name.encode('utf-8')
+ exists = os.path.exists(full_path_name)
+ is_file = os.path.isfile(full_path_name)
+ if not exists or not is_file:
return full_path_name, False
path, current_name, name = simplify_name(full_path_name,
@@ -1206,8 +1213,12 @@ def try_fix_file(filename, make_copy=True):
path, current_name, simplified_ref_name = simplify_name(
filename, check_existing=False)
+ try:
+ dirs = list(os.listdir(path))
+ except UnicodeDecodeError:
+ dirs = list(os.listdir(path.encode('utf-8')))
# check existing files in the path
- for file in sorted(list(os.listdir(path))):
+ for file in sorted(dirs):
full_file = os.sep.join([path, file])
if not os.path.isfile(full_file): # must be a file
continue