Skip to content

Commit

Permalink
Fix windows bug when "." is specified with delete/exclude
Browse files Browse the repository at this point in the history
This is needed to completely fix #778.  #780 added a partial fix,
this is needed so that this fix also works on windows.
  • Loading branch information
jamesls committed May 19, 2014
1 parent b78e1b3 commit 1d526b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion awscli/customizations/s3/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_filter(parameters):


def _get_s3_root(source_location):
return split_s3_bucket_key(source_location)[0]
return split_s3_bucket_key(os.path.abspath(source_location))[0]


def _get_local_root(source_location, dir_op):
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/customizations/s3/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,29 @@ def test_exclude_filter_with_delete(self):
("The --delete flag was not applied to the receiving "
"end, the 'bar.py' file was deleted even though it was excluded."))

def test_exclude_filter_with_relative_path(self):
# Same test as test_exclude_filter_with_delete, except we don't
# use an absolute path on the source dir.
bucket_name = self.create_bucket()
first = self.files.create_file('foo.txt', 'contents')
second = self.files.create_file('bar.py', 'contents')
p = aws("s3 sync %s s3://%s/" % (self.files.rootdir, bucket_name))
self.assert_no_errors(p)
self.assertTrue(self.key_exists(bucket_name, key_name='bar.py'))
os.remove(second)
cwd = os.getcwd()
try:
os.chdir(self.files.rootdir)
# Note how we're using "." for the source directory.
p = aws("s3 sync . s3://%s/ --exclude '*.py' --delete" % bucket_name)
finally:
os.chdir(cwd)
self.assert_no_errors(p)
self.assertTrue(
self.key_exists(bucket_name, key_name='bar.py'),
("The --delete flag was not applied to the receiving "
"end, the 'bar.py' file was deleted even though it was excluded."))


class TestFileWithSpaces(BaseS3CLICommand):
def test_upload_download_file_with_spaces(self):
Expand Down

0 comments on commit 1d526b7

Please sign in to comment.