Permalink
Browse files

Fix walk_keys error handling of root directory on Python 2.x Windows

  • Loading branch information...
benhoyt committed Apr 8, 2017
1 parent ced8d35 commit 7eb192016d131a401b15ddaff8b7d8f8d47cb396
Showing with 7 additions and 3 deletions.
  1. +4 −2 cdnupload.py
  2. +3 −1 tests/test_file_source.py
View
@@ -36,7 +36,7 @@
__all__ = ['SourceError', 'DestinationError', 'FileSource', 'Destination',
'FileDestination', 'S3Destination', 'upload', 'delete']
__version__ = '1.0.0'
__version__ = '1.0.1'
DEFAULT_HASH_LENGTH = 16
LICENSES = ['open', 'single', 'multi']
@@ -217,8 +217,10 @@ def walk_files(self):
# Ensure that errors while walking are raised as hard errors, unless
# ignore_walk_errors is True or it's an error listing the root dir
# (on Python 2.x on Windows, error.filename includes the '*.*')
def onerror(error):
if not self.ignore_walk_errors or error.filename == walk_root:
if (not self.ignore_walk_errors or error.filename == walk_root or
error.filename == os.path.join(walk_root, '*.*')):
raise error
else:
logger.debug('ignoring error scanning source tree: %s', error)
@@ -216,7 +216,9 @@ def check_walk_error(file_source, error_path):
list(file_source.walk_files())
assert False # shouldn't get here
except OSError as error:
assert error.filename == error_path
# On Python 2.x on Windows, error.filename includes '*.*'
assert (error.filename == error_path or
error.filename == os.path.join(error_path, '*.*'))
not_exists = tmpdir.join('not_exists')
s = FileSource(not_exists.strpath)

0 comments on commit 7eb1920

Please sign in to comment.