Browse code

Merge from 0.9.8.x branch, rel 246: * s3cmd, S3/S3.py, S3/Exceptions.py: Don't abort 'sync' or 'put' on files that can't be open (e.g. Permision denied). Print a warning and skip over instead.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@255 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2008/11/16 18:43:44
Showing 4 changed files
... ...
@@ -1,5 +1,9 @@
1 1
 2008-11-16  Michal Ludvig  <michal@logix.cz>
2 2
 
3
+	Merge from 0.9.8.x branch, rel 246:
4
+	* s3cmd, S3/S3.py, S3/Exceptions.py: Don't abort 'sync' or 'put' on files
5
+	  that can't be open (e.g. Permision denied). Print a warning and skip over
6
+	  instead.
3 7
 	Merge from 0.9.8.x branch, rel 245:
4 8
 	* S3/S3.py: Escape parameters in strings. Fixes sync to and 
5 9
 	  ls of directories with spaces. (Thx Lubomir Rintel from Fedora Project)
... ...
@@ -48,5 +48,8 @@ class S3UploadError(S3Exception):
48 48
 class S3DownloadError(S3Exception):
49 49
 	pass
50 50
 
51
+class InvalidFileError(S3Exception):
52
+	pass
53
+
51 54
 class ParameterError(S3Exception):
52 55
 	pass
... ...
@@ -162,12 +162,12 @@ class S3(object):
162 162
 			raise ValueError("Expected URI type 's3', got '%s'" % uri.type)
163 163
 
164 164
 		if not os.path.isfile(filename):
165
-			raise ParameterError("%s is not a regular file" % filename)
165
+			raise InvalidFileError("%s is not a regular file" % filename)
166 166
 		try:
167 167
 			file = open(filename, "rb")
168 168
 			size = os.stat(filename)[ST_SIZE]
169 169
 		except IOError, e:
170
-			raise ParameterError("%s: %s" % (filename, e.strerror))
170
+			raise InvalidFileError("%s: %s" % (filename, e.strerror))
171 171
 		headers = SortedDict()
172 172
 		if extra_headers:
173 173
 			headers.update(extra_headers)
... ...
@@ -209,6 +209,9 @@ def cmd_object_put(args):
209 209
 		except S3UploadError, e:
210 210
 			error("Upload of '%s' failed too many times. Skipping that file." % real_filename)
211 211
 			continue
212
+		except InvalidFileError, e:
213
+			warning("File can not be uploaded: %s" % e)
214
+			continue
212 215
 		speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
213 216
 		output("File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) [%d of %d]" %
214 217
 			(file, uri_final, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],
... ...
@@ -648,6 +651,9 @@ def cmd_sync_local2remote(src, dst):
648 648
 		except S3UploadError, e:
649 649
 			error("%s: upload failed too many times. Skipping that file." % src)
650 650
 			continue
651
+		except InvalidFileError, e:
652
+			warning("File can not be uploaded: %s" % e)
653
+			continue
651 654
 		speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True)
652 655
 		output("File '%s' stored as %s (%d bytes in %0.1f seconds, %0.2f %sB/s) [%d of %d]" %
653 656
 			(src, uri, response["size"], response["elapsed"], speed_fmt[0], speed_fmt[1],