@@ -145,10 +145,6 @@ def get_file_diff(self, files_to_diff):
145
145
]
146
146
147
147
148
- class InsufficientStorageException (Exception ):
149
- """Raised when there is not enough storage space."""
150
- pass
151
-
152
148
def do_file_upload (self , filename ):
153
149
file_data = self .file_map [filename ]
154
150
if file_data .skip_upload :
@@ -168,45 +164,41 @@ def do_file_upload(self, filename):
168
164
name , ext = os .path .splitext (data ["name" ])
169
165
if not ext :
170
166
data ["name" ] = "{}.{}" .format (name , data ["file_format" ])
171
- url_response = config .SESSION .post (config .get_upload_url (), json = data )
172
- if url_response .status_code == 412 :
173
- raise InsufficientStorageException ("You have run out of storage space." )
174
- if url_response .status_code == 200 :
175
- response_data = url_response .json ()
176
- upload_url = response_data ["uploadURL" ]
177
- content_type = response_data ["mimetype" ]
178
- might_skip = response_data ["might_skip" ]
179
- if might_skip and self .check_file_exists (filename ):
180
- return
181
- b64checksum = (
182
- codecs .encode (codecs .decode (file_data .checksum , "hex" ), "base64" )
183
- .decode ()
184
- .strip ()
185
- )
186
- headers = {"Content-Type" : content_type , "Content-MD5" : b64checksum }
187
- response = config .SESSION .put (
188
- upload_url , headers = headers , data = file_obj
189
- )
190
- if response .status_code == 200 :
191
- return
167
+ url_response = config .SESSION .post (config .get_upload_url (), json = data )
168
+ if url_response .status_code == 200 :
169
+ response_data = url_response .json ()
170
+ upload_url = response_data ["uploadURL" ]
171
+ content_type = response_data ["mimetype" ]
172
+ might_skip = response_data ["might_skip" ]
173
+ if might_skip and self .check_file_exists (filename ):
174
+ return
175
+ b64checksum = (
176
+ codecs .encode (codecs .decode (file_data .checksum , "hex" ), "base64" )
177
+ .decode ()
178
+ .strip ()
179
+ )
180
+ headers = {"Content-Type" : content_type , "Content-MD5" : b64checksum }
181
+ response = config .SESSION .put (
182
+ upload_url , headers = headers , data = file_obj
183
+ )
184
+ if response .status_code == 200 :
185
+ return
192
186
raise RequestException (
193
187
"Error uploading file {}, response code: {} - {}" .format (
194
188
filename , response .status_code , response .text
195
189
)
196
190
)
197
- else :
198
- raise RequestException (
199
- "Error retrieving upload URL for file {}, response code: {} - {}" .format (
200
- filename , url_response .status_code , url_response .text
191
+ else :
192
+ raise RequestException (
193
+ "Error retrieving upload URL for file {}, response code: {} - {}" .format (
194
+ filename , url_response .status_code , url_response .text
195
+ )
201
196
)
202
- )
203
197
204
198
def _handle_upload (self , f ):
205
199
try :
206
200
self .do_file_upload (f )
207
201
self .uploaded_files .append (f )
208
- except InsufficientStorageException as e :
209
- raise e
210
202
except Exception as e :
211
203
config .LOGGER .error (e )
212
204
self .failed_uploads [f ] = str (e )
0 commit comments