Skip to content

Commit

Permalink
Fix walk_keys error handling of root directory on Python 2.x Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Apr 8, 2017
1 parent ced8d35 commit 7eb1920
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cdnupload.py
Expand Up @@ -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']
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_file_source.py
Expand Up @@ -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)
Expand Down

0 comments on commit 7eb1920

Please sign in to comment.