Skip to content
Browse files

* s3cmd, S3/S3.py: Ignore inaccessible (and missing) files

  on upload.
* run-tests.py: Extended [sync] test to verify correct
  handling of inaccessible files.
* testsuite/permission-tests: New testsuite files.



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@441 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
1 parent e35260e commit 2edf0e8220fadb64f3853d8730d0cdb830079cb2 ludvigm committed Oct 24, 2010
View
8 ChangeLog
@@ -1,3 +1,11 @@
+2010-10-25 Michal Ludvig <mludvig@logix.net.nz>
+
+ * s3cmd, S3/S3.py: Ignore inaccessible (and missing) files
+ on upload.
+ * run-tests.py: Extended [sync] test to verify correct
+ handling of inaccessible files.
+ * testsuite/permission-tests: New testsuite files.
+
2010-10-24 Michal Ludvig <mludvig@logix.net.nz>
* S3/S3.py: "Stringify" all headers. Httplib should do
View
2 S3/S3.py
@@ -255,7 +255,7 @@ def object_put(self, filename, uri, extra_headers = None, extra_label = ""):
try:
file = open(filename, "rb")
size = os.stat(filename)[ST_SIZE]
- except IOError, e:
+ except (IOError, OSError), e:
raise InvalidFileError(u"%s: %s" % (unicodise(filename), e.strerror))
headers = SortedDict(ignore_case = True)
if extra_headers:
View
7 run-tests.py
@@ -58,6 +58,10 @@
# TODO: also unpack if the tarball is newer than the directory timestamp
# for instance when a new version was pulled from SVN.
+## Fix up permissions for permission-denied tests
+os.chmod("testsuite/permission-tests/permission-denied-dir", 0444)
+os.chmod("testsuite/permission-tests/permission-denied.txt", 0000)
+
def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
def command_output():
print "----"
@@ -251,8 +255,9 @@ def pbucket(tail):
## ====== Sync to S3
test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
must_find = [ "WARNING: 32 non-printable characters replaced in: crappy-file-name/non-printables ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\]^<>%%\"'#{}`&?.end",
+ "WARNING: File can not be uploaded: testsuite/permission-tests/permission-denied.txt: Permission denied",
"stored as '%s/xyz/crappy-file-name/non-printables ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\\]^<>%%%%\"'#{}`&?.end'" % pbucket(1) ],
- must_not_find_re = [ "\.svn/", "\.png$" ])
+ must_not_find_re = [ "\.svn/", "\.png$", "permission-denied-dir" ])
if have_encoding:
## ====== Sync UTF-8 / GBK / ... to S3
View
19 s3cmd
@@ -972,7 +972,10 @@ def cmd_sync_local2remote(args):
import pwd, grp
attrs = {}
src = deunicodise(src)
- st = os.stat_result(os.stat(src))
+ try:
+ st = os.stat_result(os.stat(src))
+ except OSError, e:
+ raise InvalidFileError(u"%s: %s" % (unicodise(src), e.strerror))
for attr in cfg.preserve_attrs_list:
if attr == 'uname':
try:
@@ -1073,18 +1076,18 @@ def cmd_sync_local2remote(args):
uri = S3Uri(item['remote_uri'])
seq_label = "[%d of %d]" % (seq, local_count)
extra_headers = copy(cfg.extra_headers)
- if cfg.preserve_attrs:
- attr_header = _build_attr_header(src)
- debug(u"attr_header: %s" % attr_header)
- extra_headers.update(attr_header)
try:
+ if cfg.preserve_attrs:
+ attr_header = _build_attr_header(src)
+ debug(u"attr_header: %s" % attr_header)
+ extra_headers.update(attr_header)
response = s3.object_put(src, uri, extra_headers, extra_label = seq_label)
- except S3UploadError, e:
- error(u"%s: upload failed too many times. Skipping that file." % item['full_name_unicode'])
- continue
except InvalidFileError, e:
warning(u"File can not be uploaded: %s" % e)
continue
+ except S3UploadError, e:
+ error(u"%s: upload failed too many times. Skipping that file." % item['full_name_unicode'])
+ continue
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
if not cfg.progress_meter:
output(u"File '%s' stored as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s) %s" %
View
1 testsuite/permission-tests/permission-denied-dir/inaccessible.txt
@@ -0,0 +1 @@
+inaccessible
View
1 testsuite/permission-tests/permission-denied.txt
@@ -0,0 +1 @@
+permission denied

0 comments on commit 2edf0e8

Please sign in to comment.
Something went wrong with that request. Please try again.