git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@442 830e0280-6d2a-0410-9c65-932aecc39d9d
Michal Ludvig authored on 2010/10/24 22:14:56... | ... |
@@ -1,5 +1,11 @@ |
1 | 1 |
2010-10-25 Michal Ludvig <mludvig@logix.net.nz> |
2 | 2 |
|
3 |
+ * s3cmd: Don't fail when a local node is a directory |
|
4 |
+ and we expected a file. (as if for example /etc/passwd |
|
5 |
+ was a dir) |
|
6 |
+ |
|
7 |
+2010-10-25 Michal Ludvig <mludvig@logix.net.nz> |
|
8 |
+ |
|
3 | 9 |
* s3cmd, S3/S3.py: Ignore inaccessible (and missing) files |
4 | 10 |
on upload. |
5 | 11 |
* run-tests.py: Extended [sync] test to verify correct |
... | ... |
@@ -112,6 +112,9 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], |
112 | 112 |
if run_tests.count(test_counter) == 0 or exclude_tests.count(test_counter) > 0: |
113 | 113 |
return skip() |
114 | 114 |
|
115 |
+ if not cmd_args: |
|
116 |
+ return skip() |
|
117 |
+ |
|
115 | 118 |
p = Popen(cmd_args, stdout = PIPE, stderr = STDOUT, universal_newlines = True) |
116 | 119 |
stdout, stderr = p.communicate() |
117 | 120 |
if retcode != p.returncode: |
... | ... |
@@ -151,7 +154,7 @@ def test_s3cmd(label, cmd_args = [], **kwargs): |
151 | 151 |
|
152 | 152 |
def test_mkdir(label, dir_name): |
153 | 153 |
if os.name in ("posix", "nt"): |
154 |
- cmd = ['mkdir'] |
|
154 |
+ cmd = ['mkdir', '-p'] |
|
155 | 155 |
else: |
156 | 156 |
print "Unknown platform: %s" % os.name |
157 | 157 |
sys.exit(1) |
... | ... |
@@ -169,6 +172,8 @@ def test_rmdir(label, dir_name): |
169 | 169 |
sys.exit(1) |
170 | 170 |
cmd.append(dir_name) |
171 | 171 |
return test(label, cmd) |
172 |
+ else: |
|
173 |
+ return test(label, []) |
|
172 | 174 |
|
173 | 175 |
def test_flushdir(label, dir_name): |
174 | 176 |
test_rmdir(label + "(rm)", dir_name) |
... | ... |
@@ -297,6 +302,19 @@ test_s3cmd("Sync from S3", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'], |
297 | 297 |
must_find = must_find) |
298 | 298 |
|
299 | 299 |
|
300 |
+## ====== Remove 'demo' directory |
|
301 |
+test_rmdir("Remove 'demo/'", "testsuite-out/xyz/demo/") |
|
302 |
+ |
|
303 |
+ |
|
304 |
+## ====== Create dir with name of a file |
|
305 |
+test_mkdir("Create some-file.xml dir", "testsuite-out/xyz/demo/some-file.xml") |
|
306 |
+ |
|
307 |
+ |
|
308 |
+## ====== Skip dst dirs |
|
309 |
+test_s3cmd("Skip over dir", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'], |
|
310 |
+ must_find = "WARNING: testsuite-out/xyz/demo/some-file.xml is a directory - skipping over") |
|
311 |
+ |
|
312 |
+ |
|
300 | 313 |
## ====== Clean up local destination dir |
301 | 314 |
test_flushdir("Clean testsuite-out/", "testsuite-out") |
302 | 315 |
|
... | ... |
@@ -930,6 +930,9 @@ def cmd_sync_remote2local(args): |
930 | 930 |
if e.errno in (errno.EPERM, errno.EACCES): |
931 | 931 |
warning(u"%s not writable: %s" % (dst_file, e.strerror)) |
932 | 932 |
continue |
933 |
+ if e.errno == errno.EISDIR: |
|
934 |
+ warning(u"%s is a directory - skipping over" % dst_file) |
|
935 |
+ continue |
|
933 | 936 |
raise e |
934 | 937 |
except KeyboardInterrupt: |
935 | 938 |
try: dst_stream.close() |