From 2fc501f398c078649921f812fc710d2477ab7acd Mon Sep 17 00:00:00 2001 From: "Arav K." Date: Fri, 28 Jun 2024 08:11:10 +0200 Subject: [PATCH] [beets.util.hidden] Disambiguate Win32 attribute logic See: --- beets/util/hidden.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/beets/util/hidden.py b/beets/util/hidden.py index 077fb546b..d2c66fac0 100644 --- a/beets/util/hidden.py +++ b/beets/util/hidden.py @@ -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":