Skip to content

Commit

Permalink
* s3cmd: Don't fail when a local node is a directory
Browse files Browse the repository at this point in the history
  and we expected a file. (as if for example /etc/passwd 
  was a dir)



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@442 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information
ludvigm committed Oct 24, 2010
1 parent 2edf0e8 commit 2402847
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
2010-10-25 Michal Ludvig <mludvig@logix.net.nz>

* s3cmd: Don't fail when a local node is a directory
and we expected a file. (as if for example /etc/passwd
was a dir)

2010-10-25 Michal Ludvig <mludvig@logix.net.nz> 2010-10-25 Michal Ludvig <mludvig@logix.net.nz>


* s3cmd, S3/S3.py: Ignore inaccessible (and missing) files * s3cmd, S3/S3.py: Ignore inaccessible (and missing) files
Expand Down
20 changes: 19 additions & 1 deletion run-tests.py
Expand Up @@ -112,6 +112,9 @@ def compile_list(_list, regexps = False):
if run_tests.count(test_counter) == 0 or exclude_tests.count(test_counter) > 0: if run_tests.count(test_counter) == 0 or exclude_tests.count(test_counter) > 0:
return skip() return skip()


if not cmd_args:
return skip()

p = Popen(cmd_args, stdout = PIPE, stderr = STDOUT, universal_newlines = True) p = Popen(cmd_args, stdout = PIPE, stderr = STDOUT, universal_newlines = True)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if retcode != p.returncode: if retcode != p.returncode:
Expand Down Expand Up @@ -151,7 +154,7 @@ def test_s3cmd(label, cmd_args = [], **kwargs):


def test_mkdir(label, dir_name): def test_mkdir(label, dir_name):
if os.name in ("posix", "nt"): if os.name in ("posix", "nt"):
cmd = ['mkdir'] cmd = ['mkdir', '-p']
else: else:
print "Unknown platform: %s" % os.name print "Unknown platform: %s" % os.name
sys.exit(1) sys.exit(1)
Expand All @@ -169,6 +172,8 @@ def test_rmdir(label, dir_name):
sys.exit(1) sys.exit(1)
cmd.append(dir_name) cmd.append(dir_name)
return test(label, cmd) return test(label, cmd)
else:
return test(label, [])


def test_flushdir(label, dir_name): def test_flushdir(label, dir_name):
test_rmdir(label + "(rm)", dir_name) test_rmdir(label + "(rm)", dir_name)
Expand Down Expand Up @@ -297,6 +302,19 @@ def pbucket(tail):
must_find = must_find) must_find = must_find)




## ====== Remove 'demo' directory
test_rmdir("Remove 'demo/'", "testsuite-out/xyz/demo/")


## ====== Create dir with name of a file
test_mkdir("Create some-file.xml dir", "testsuite-out/xyz/demo/some-file.xml")


## ====== Skip dst dirs
test_s3cmd("Skip over dir", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
must_find = "WARNING: testsuite-out/xyz/demo/some-file.xml is a directory - skipping over")


## ====== Clean up local destination dir ## ====== Clean up local destination dir
test_flushdir("Clean testsuite-out/", "testsuite-out") test_flushdir("Clean testsuite-out/", "testsuite-out")


Expand Down
3 changes: 3 additions & 0 deletions s3cmd
Expand Up @@ -930,6 +930,9 @@ def cmd_sync_remote2local(args):
if e.errno in (errno.EPERM, errno.EACCES): if e.errno in (errno.EPERM, errno.EACCES):
warning(u"%s not writable: %s" % (dst_file, e.strerror)) warning(u"%s not writable: %s" % (dst_file, e.strerror))
continue continue
if e.errno == errno.EISDIR:
warning(u"%s is a directory - skipping over" % dst_file)
continue
raise e raise e
except KeyboardInterrupt: except KeyboardInterrupt:
try: dst_stream.close() try: dst_stream.close()
Expand Down

0 comments on commit 2402847

Please sign in to comment.