Skip to content

Commit

Permalink
Merge pull request #31 from smunkel/master
Browse files Browse the repository at this point in the history
Dont warn about unknown file if it is a system file (Bug 1712)
  • Loading branch information
thp committed Dec 17, 2012
2 parents f6c6613 + 2b9ef81 commit faa9bb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/gpodder/model.py
Expand Up @@ -924,7 +924,7 @@ def check_download_folder(self):
found = True
break

if not found:
if not found and not util.is_system_file(filename):
logger.warn('Unknown external file: %s', filename)

@classmethod
Expand Down
35 changes: 25 additions & 10 deletions src/gpodder/util.py
Expand Up @@ -67,6 +67,13 @@
import StringIO
import xml.dom.minidom

if gpodder.win32:
try:
import win32file
except ImportError:
logger.warn('Running on Win32 but win32api/win32file not installed.')
win32file = None

_ = gpodder.gettext
N_ = gpodder.ngettext

Expand Down Expand Up @@ -411,25 +418,33 @@ def file_age_to_string(days):
return N_('%(count)d day ago', '%(count)d days ago', days) % {'count':days}


def is_system_file(filename):
"""
Checks to see if the given file is a system file.
"""
if gpodder.win32 and win32file is not None:
result = win32file.GetFileAttributes(filename)
#-1 is returned by GetFileAttributes when an error occurs
#0x4 is the FILE_ATTRIBUTE_SYSTEM constant
return result != -1 and result & 0x4 != 0
else:
return False


def get_free_disk_space_win32(path):
"""
Win32-specific code to determine the free disk space remaining
for a given path. Uses code from:
http://mail.python.org/pipermail/python-list/2003-May/203223.html
"""
if win32file is None:
# Cannot determine free disk space
return 0

drive, tail = os.path.splitdrive(path)

try:
import win32file
userFree, userTotal, freeOnDisk = win32file.GetDiskFreeSpaceEx(drive)
return userFree
except ImportError:
logger.warn('Running on Win32 but win32api/win32file not installed.')

# Cannot determine free disk space
return 0
userFree, userTotal, freeOnDisk = win32file.GetDiskFreeSpaceEx(drive)
return userFree


def get_free_disk_space(path):
Expand Down

0 comments on commit faa9bb7

Please sign in to comment.