Skip to content

Commit

Permalink
Merge pull request #6836 from drew2a/fix/6832
Browse files Browse the repository at this point in the history
Add `UnicodeEncodeError` to the except block
  • Loading branch information
drew2a authored Mar 29, 2022
2 parents 948f908 + 95c60b0 commit f6b773c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/tribler/gui/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ def is_dir_writable(path):
:return: True if writable, False otherwise
"""

random_name = "tribler_temp_delete_me_" + str(uuid4())
directory = Path(path)
random_file = directory / f'tribler_temp_delete_me_{uuid4()}'
try:
if not os.path.exists(path):
os.makedirs(path)
open(os.path.join(path, random_name), 'w')
os.remove(os.path.join(path, random_name))
except OSError as os_error:
return False, os_error
directory.mkdir(parents=True, exist_ok=True)
random_file.open('w')
random_file.unlink()
except (OSError, UnicodeEncodeError) as e:
return False, e
else:
return True, None

Expand Down

0 comments on commit f6b773c

Please sign in to comment.