Skip to content

Commit

Permalink
* s3cmd, S3/S3.py: Ignore inaccessible (and missing) files
Browse files Browse the repository at this point in the history
  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
mludvig committed Oct 24, 2010
1 parent 259d955 commit f863a31
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion S3/S3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "----"
Expand Down Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions s3cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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" %
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inaccessible
1 change: 1 addition & 0 deletions testsuite/permission-tests/permission-denied.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
permission denied

0 comments on commit f863a31

Please sign in to comment.