Skip to content

Commit

Permalink
Giving some air
Browse files Browse the repository at this point in the history
  • Loading branch information
SeqLaz committed Oct 24, 2024
1 parent b9a8243 commit f157301
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libqfieldsync/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def isascii(filename: str) -> bool:
except UnicodeEncodeError:
return False


def is_valid_filename(filename: str) -> bool:
"""
Check if the filename is valid.
Expand All @@ -201,8 +202,10 @@ def is_valid_filename(filename: str) -> bool:
r'[^\\\/:*"?<>|]{1,254}'
r"(?<![\s\.])$"
)

return bool(pattern.match(filename))


def is_valid_filepath(path: str) -> bool:
"""
Check if the entire path is valid by validating each part of the path.
Expand All @@ -211,4 +214,5 @@ def is_valid_filepath(path: str) -> bool:
for part in path_obj.parts:
if not is_valid_filename(part):
return False
return True

return True

0 comments on commit f157301

Please sign in to comment.