1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-05 17:05:03 -05:00

Merge pull request #1309 from TagForce/hiddenfolders

Added Hidden Folder check for Windows Attributes
This commit is contained in:
Alexandre Beloin 2015-02-16 08:39:32 -05:00
commit 07f6ddc27f
2 changed files with 16 additions and 2 deletions

View File

@ -19,6 +19,7 @@
from __future__ import with_statement
import os
import ctypes
import random
import re
import shutil
@ -951,8 +952,21 @@ def is_hidden_folder(folder):
On Linux based systems hidden folders start with . (dot)
folder: Full path of folder to check
"""
def is_hidden(filepath):
name = os.path.basename(os.path.abspath(filepath))
return name.startswith('.') or has_hidden_attribute(filepath)
def has_hidden_attribute(filepath):
try:
attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath))
assert attrs != -1
result = bool(attrs & 2)
except (AttributeError, AssertionError):
result = False
return result
if ek.ek(os.path.isdir, folder):
if ek.ek(os.path.basename, folder).startswith('.'):
if is_hidden(folder):
return True
return False

View File

@ -251,7 +251,7 @@ def validateDir(path, dirName, nzbNameOriginal, failed, result):
process_failed(os.path.join(path, dirName), nzbNameOriginal, result)
return False
if helpers.is_hidden_folder(dirName):
if helpers.is_hidden_folder(os.path.join(path, dirName)):
result.output += logHelper(u"Ignoring hidden folder: " + dirName, logger.DEBUG)
return False