[beets.util.hidden] Disambiguate Win32 attribute logic

See: <https://github.com/beetbox/beets/pull/5341#discussion_r1658172880>
This commit is contained in:
Arav K. 2024-06-28 08:11:10 +02:00
parent 484400f701
commit 2fc501f398

View file

@ -43,8 +43,12 @@ def is_hidden(path: Union[bytes, Path]) -> bool:
# Retrieve the attributes for the file.
attrs = ctypes.windll.kernel32.GetFileAttributesW(str(path))
# Ensure we have valid attributes and compare them against the mask.
return attrs >= 0 and attrs & hidden_mask
# Ensure the attribute mask is valid.
if attrs < 0:
return False
# Check for the hidden attribute.
return attrs & hidden_mask
# On OS X, we check for an FS-provided attribute.
if sys.platform == "darwin":