Index: branches/FileBackend/phase3/includes/filerepo/backend/SwiftFileBackend.php |
— | — | @@ -67,9 +67,9 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | | - * @see FileBackend::doStoreInternal() |
| 71 | + * @see FileBackend::doCopyInternal() |
72 | 72 | */ |
73 | | - protected function doStoreInternal( array $params ) { |
| 73 | + protected function doCreateInternal( array $params ) { |
74 | 74 | $status = Status::newGood(); |
75 | 75 | |
76 | 76 | list( $dstCont, $destRel ) = $this->resolveStoragePathReal( $params['dst'] ); |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | try { |
91 | 91 | $dContObj = $conn->get_container( $dstCont ); |
92 | 92 | } catch ( NoSuchContainerException $e ) { |
93 | | - $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
| 93 | + $status->fatal( 'backend-fail-create', $params['dst'] ); |
94 | 94 | return $status; |
95 | 95 | } catch ( InvalidResponseException $e ) { |
96 | 96 | $status->fatal( 'backend-fail-connect' ); |
— | — | @@ -119,14 +119,17 @@ |
120 | 120 | return $status; |
121 | 121 | } |
122 | 122 | |
123 | | - // (d) Actually store the object |
| 123 | + // (d) Get a SHA-1 hash of the object |
| 124 | + $sha1Hash = wfBaseConvert( sha1( $params['content'] ), 16, 36, 31 ); |
| 125 | + |
| 126 | + // (e) Actually create the object |
124 | 127 | try { |
125 | 128 | $obj = $dContObj->create_object( $destRel ); |
126 | | - $obj->load_from_filename( $params['src'], True ); |
| 129 | + // Note: metadata keys stored as [Upper case char][[Lower case char]...] |
| 130 | + $obj->metadata = array( 'Sha1base36' => $sha1Hash ); |
| 131 | + $obj->write( $params['content'] ); |
127 | 132 | } catch ( BadContentTypeException $e ) { |
128 | 133 | $status->fatal( 'backend-fail-contenttype', $params['dst'] ); |
129 | | - } catch ( IOException $e ) { |
130 | | - $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
131 | 134 | } catch ( InvalidResponseException $e ) { |
132 | 135 | $status->fatal( 'backend-fail-connect' ); |
133 | 136 | } catch ( Exception $e ) { // some other exception? |
— | — | @@ -138,17 +141,11 @@ |
139 | 142 | } |
140 | 143 | |
141 | 144 | /** |
142 | | - * @see FileBackend::doCopyInternal() |
| 145 | + * @see FileBackend::doStoreInternal() |
143 | 146 | */ |
144 | | - protected function doCopyInternal( array $params ) { |
| 147 | + protected function doStoreInternal( array $params ) { |
145 | 148 | $status = Status::newGood(); |
146 | 149 | |
147 | | - list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
148 | | - if ( $srcRel === null ) { |
149 | | - $status->fatal( 'backend-fail-invalidpath', $params['src'] ); |
150 | | - return $status; |
151 | | - } |
152 | | - |
153 | 150 | list( $dstCont, $destRel ) = $this->resolveStoragePathReal( $params['dst'] ); |
154 | 151 | if ( $destRel === null ) { |
155 | 152 | $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); |
— | — | @@ -162,9 +159,8 @@ |
163 | 160 | return $status; |
164 | 161 | } |
165 | 162 | |
166 | | - // (b) Check the source and destination containers |
| 163 | + // (b) Check the destination container |
167 | 164 | try { |
168 | | - $sContObj = $conn->get_container( $srcCont ); |
169 | 165 | $dContObj = $conn->get_container( $dstCont ); |
170 | 166 | } catch ( NoSuchContainerException $e ) { |
171 | 167 | $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
— | — | @@ -197,10 +193,23 @@ |
198 | 194 | return $status; |
199 | 195 | } |
200 | 196 | |
201 | | - // (d) Actually copy the file to the destination |
| 197 | + // (d) Get a SHA-1 hash of the object |
| 198 | + $sha1Hash = sha1_file( $params['src'] ); |
| 199 | + if ( $sha1Hash === false ) { // source doesn't exist? |
| 200 | + $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
| 201 | + return $status; |
| 202 | + } |
| 203 | + $sha1Hash = wfBaseConvert( $sha1Hash, 16, 36, 31 ); |
| 204 | + |
| 205 | + // (e) Actually store the object |
202 | 206 | try { |
203 | | - $sContObj->copy_object_to( $srcRel, $dContObj, $destRel ); |
204 | | - } catch ( NoSuchObjectException $e ) { // source object does not exist |
| 207 | + $obj = $dContObj->create_object( $destRel ); |
| 208 | + // Note: metadata keys stored as [Upper case char][[Lower case char]...] |
| 209 | + $obj->metadata = array( 'Sha1base36' => $sha1Hash ); |
| 210 | + $obj->load_from_filename( $params['src'], True ); // calls $obj->write() |
| 211 | + } catch ( BadContentTypeException $e ) { |
| 212 | + $status->fatal( 'backend-fail-contenttype', $params['dst'] ); |
| 213 | + } catch ( IOException $e ) { |
205 | 214 | $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
206 | 215 | } catch ( InvalidResponseException $e ) { |
207 | 216 | $status->fatal( 'backend-fail-connect' ); |
— | — | @@ -213,9 +222,9 @@ |
214 | 223 | } |
215 | 224 | |
216 | 225 | /** |
217 | | - * @see FileBackend::doDeleteInternal() |
| 226 | + * @see FileBackend::doCopyInternal() |
218 | 227 | */ |
219 | | - protected function doDeleteInternal( array $params ) { |
| 228 | + protected function doCopyInternal( array $params ) { |
220 | 229 | $status = Status::newGood(); |
221 | 230 | |
222 | 231 | list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
— | — | @@ -224,6 +233,12 @@ |
225 | 234 | return $status; |
226 | 235 | } |
227 | 236 | |
| 237 | + list( $dstCont, $destRel ) = $this->resolveStoragePathReal( $params['dst'] ); |
| 238 | + if ( $destRel === null ) { |
| 239 | + $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); |
| 240 | + return $status; |
| 241 | + } |
| 242 | + |
228 | 243 | // (a) Get a swift proxy connection |
229 | 244 | $conn = $this->getConnection(); |
230 | 245 | if ( !$conn ) { |
— | — | @@ -231,11 +246,12 @@ |
232 | 247 | return $status; |
233 | 248 | } |
234 | 249 | |
235 | | - // (b) Check the source container |
| 250 | + // (b) Check the source and destination containers |
236 | 251 | try { |
237 | 252 | $sContObj = $conn->get_container( $srcCont ); |
| 253 | + $dContObj = $conn->get_container( $dstCont ); |
238 | 254 | } catch ( NoSuchContainerException $e ) { |
239 | | - $status->fatal( 'backend-fail-delete', $params['src'] ); |
| 255 | + $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
240 | 256 | return $status; |
241 | 257 | } catch ( InvalidResponseException $e ) { |
242 | 258 | $status->fatal( 'backend-fail-connect' ); |
— | — | @@ -246,32 +262,49 @@ |
247 | 263 | return $status; |
248 | 264 | } |
249 | 265 | |
250 | | - // (c) Actually delete the object |
| 266 | + // (c) Check if the destination object already exists |
251 | 267 | try { |
252 | | - $sContObj->delete_object( $srcRel ); |
| 268 | + $dContObj->get_object( $destRel ); // throws NoSuchObjectException |
| 269 | + // NoSuchObjectException not thrown: file must exist |
| 270 | + if ( empty( $params['overwriteDest'] ) ) { |
| 271 | + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
| 272 | + return $status; |
| 273 | + } |
253 | 274 | } catch ( NoSuchObjectException $e ) { |
254 | | - if ( empty( $params['ignoreMissingSource'] ) ) { |
255 | | - $status->fatal( 'backend-fail-delete', $params['src'] ); |
256 | | - } |
| 275 | + // NoSuchObjectException thrown: file does not exist |
257 | 276 | } catch ( InvalidResponseException $e ) { |
258 | 277 | $status->fatal( 'backend-fail-connect' ); |
| 278 | + return $status; |
259 | 279 | } catch ( Exception $e ) { // some other exception? |
260 | 280 | $status->fatal( 'backend-fail-internal' ); |
261 | 281 | $this->logException( $e, __METHOD__, $params ); |
| 282 | + return $status; |
262 | 283 | } |
263 | 284 | |
| 285 | + // (d) Actually copy the file to the destination |
| 286 | + try { |
| 287 | + $sContObj->copy_object_to( $srcRel, $dContObj, $destRel ); |
| 288 | + } catch ( NoSuchObjectException $e ) { // source object does not exist |
| 289 | + $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
| 290 | + } catch ( InvalidResponseException $e ) { |
| 291 | + $status->fatal( 'backend-fail-connect' ); |
| 292 | + } catch ( Exception $e ) { // some other exception? |
| 293 | + $status->fatal( 'backend-fail-internal' ); |
| 294 | + $this->logException( $e, __METHOD__, $params ); |
| 295 | + } |
| 296 | + |
264 | 297 | return $status; |
265 | 298 | } |
266 | 299 | |
267 | 300 | /** |
268 | | - * @see FileBackend::doCopyInternal() |
| 301 | + * @see FileBackend::doDeleteInternal() |
269 | 302 | */ |
270 | | - protected function doCreateInternal( array $params ) { |
| 303 | + protected function doDeleteInternal( array $params ) { |
271 | 304 | $status = Status::newGood(); |
272 | 305 | |
273 | | - list( $dstCont, $destRel ) = $this->resolveStoragePathReal( $params['dst'] ); |
274 | | - if ( $destRel === null ) { |
275 | | - $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); |
| 306 | + list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
| 307 | + if ( $srcRel === null ) { |
| 308 | + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); |
276 | 309 | return $status; |
277 | 310 | } |
278 | 311 | |
— | — | @@ -282,11 +315,11 @@ |
283 | 316 | return $status; |
284 | 317 | } |
285 | 318 | |
286 | | - // (b) Check the destination container |
| 319 | + // (b) Check the source container |
287 | 320 | try { |
288 | | - $dContObj = $conn->get_container( $dstCont ); |
| 321 | + $sContObj = $conn->get_container( $srcCont ); |
289 | 322 | } catch ( NoSuchContainerException $e ) { |
290 | | - $status->fatal( 'backend-fail-create', $params['dst'] ); |
| 323 | + $status->fatal( 'backend-fail-delete', $params['src'] ); |
291 | 324 | return $status; |
292 | 325 | } catch ( InvalidResponseException $e ) { |
293 | 326 | $status->fatal( 'backend-fail-connect' ); |
— | — | @@ -297,45 +330,27 @@ |
298 | 331 | return $status; |
299 | 332 | } |
300 | 333 | |
301 | | - // (c) Check if the destination object already exists |
| 334 | + // (c) Actually delete the object |
302 | 335 | try { |
303 | | - $dContObj->get_object( $destRel ); // throws NoSuchObjectException |
304 | | - // NoSuchObjectException not thrown: file must exist |
305 | | - if ( empty( $params['overwriteDest'] ) ) { |
306 | | - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
307 | | - return $status; |
| 336 | + $sContObj->delete_object( $srcRel ); |
| 337 | + } catch ( NoSuchObjectException $e ) { |
| 338 | + if ( empty( $params['ignoreMissingSource'] ) ) { |
| 339 | + $status->fatal( 'backend-fail-delete', $params['src'] ); |
308 | 340 | } |
309 | | - } catch ( NoSuchObjectException $e ) { |
310 | | - // NoSuchObjectException thrown: file does not exist |
311 | 341 | } catch ( InvalidResponseException $e ) { |
312 | 342 | $status->fatal( 'backend-fail-connect' ); |
313 | | - return $status; |
314 | 343 | } catch ( Exception $e ) { // some other exception? |
315 | 344 | $status->fatal( 'backend-fail-internal' ); |
316 | 345 | $this->logException( $e, __METHOD__, $params ); |
317 | | - return $status; |
318 | 346 | } |
319 | 347 | |
320 | | - // (d) Actually create the object |
321 | | - try { |
322 | | - $obj = $dContObj->create_object( $destRel ); |
323 | | - $obj->write( $params['content'] ); |
324 | | - } catch ( BadContentTypeException $e ) { |
325 | | - $status->fatal( 'backend-fail-contenttype', $params['dst'] ); |
326 | | - } catch ( InvalidResponseException $e ) { |
327 | | - $status->fatal( 'backend-fail-connect' ); |
328 | | - } catch ( Exception $e ) { // some other exception? |
329 | | - $status->fatal( 'backend-fail-internal' ); |
330 | | - $this->logException( $e, __METHOD__, $params ); |
331 | | - } |
332 | | - |
333 | 348 | return $status; |
334 | 349 | } |
335 | 350 | |
336 | 351 | /** |
337 | | - * @see FileBackend::prepate() |
| 352 | + * @see FileBackend::doPrepareInternal() |
338 | 353 | */ |
339 | | - protected function doPrepare( $fullCont, $dir, array $params ) { |
| 354 | + protected function doPrepareInternal( $fullCont, $dir, array $params ) { |
340 | 355 | $status = Status::newGood(); |
341 | 356 | |
342 | 357 | // (a) Get a swift proxy connection |
— | — | @@ -348,6 +363,8 @@ |
349 | 364 | // (b) Create the destination container |
350 | 365 | try { |
351 | 366 | $conn->create_container( $fullCont ); |
| 367 | + } catch ( InvalidResponseException $e ) { |
| 368 | + $status->fatal( 'backend-fail-connect' ); |
352 | 369 | } catch ( Exception $e ) { // some other exception? |
353 | 370 | $status->fatal( 'backend-fail-internal' ); |
354 | 371 | $this->logException( $e, __METHOD__, $params ); |
— | — | @@ -357,9 +374,9 @@ |
358 | 375 | } |
359 | 376 | |
360 | 377 | /** |
361 | | - * @see FileBackend::secure() |
| 378 | + * @see FileBackend::doSecureInternal() |
362 | 379 | */ |
363 | | - protected function doSecure( $fullCont, $dir, array $params ) { |
| 380 | + protected function doSecureInternal( $fullCont, $dir, array $params ) { |
364 | 381 | $status = Status::newGood(); |
365 | 382 | // @TODO: restrict container from $this->swiftProxyUser |
366 | 383 | return $status; // badgers? We don't need no steenking badgers! |
— | — | @@ -368,7 +385,7 @@ |
369 | 386 | /** |
370 | 387 | * @see FileBackend::doFileExists() |
371 | 388 | */ |
372 | | - protected function doFileExists( array $params ) { |
| 389 | + protected function doGetFileStat( array $params ) { |
373 | 390 | list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
374 | 391 | if ( $srcRel === null ) { |
375 | 392 | return false; // invalid storage path |
— | — | @@ -376,59 +393,34 @@ |
377 | 394 | |
378 | 395 | $conn = $this->getConnection(); |
379 | 396 | if ( !$conn ) { |
380 | | - return false; // fail vs not exists? |
| 397 | + return null; |
381 | 398 | } |
382 | 399 | |
| 400 | + $stat = false; |
383 | 401 | try { |
384 | 402 | $container = $conn->get_container( $srcCont ); |
385 | | - $container->get_object( $srcRel ); |
386 | | - $exists = true; |
387 | | - } catch ( NoSuchContainerException $e ) { |
388 | | - $exists = false; |
389 | | - } catch ( NoSuchObjectException $e ) { |
390 | | - $exists = false; |
391 | | - } catch ( Exception $e ) { // some other exception? |
392 | | - $exists = false; // fail vs not exists? |
393 | | - $this->logException( $e, __METHOD__, $params ); |
394 | | - } |
395 | | - |
396 | | - return $exists; |
397 | | - } |
398 | | - |
399 | | - /** |
400 | | - * @see FileBackend::doGetFileTimestamp() |
401 | | - */ |
402 | | - protected function doGetFileTimestamp( array $params ) { |
403 | | - list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
404 | | - if ( $srcRel === null ) { |
405 | | - return false; // invalid storage path |
406 | | - } |
407 | | - |
408 | | - $conn = $this->getConnection(); |
409 | | - if ( !$conn ) { |
410 | | - $status->fatal( 'backend-fail-connect' ); |
411 | | - return $status; |
412 | | - } |
413 | | - |
414 | | - try { |
415 | | - $container = $conn->get_container( $srcCont); |
416 | 403 | $obj = $container->get_object( $srcRel ); |
| 404 | + // Convert "Tue, 03 Jan 2012 22:01:04 GMT" to TS_MW |
| 405 | + $date = DateTime::createFromFormat( 'D, d F Y G:i:s e', $obj->last_modified ); |
| 406 | + if ( $date ) { |
| 407 | + $stat = array( |
| 408 | + 'mtime' => $date->format( 'YmdHis' ), |
| 409 | + 'size' => $obj->content_length, |
| 410 | + 'sha1' => $obj->metadata['Sha1base36'] |
| 411 | + ); |
| 412 | + } else { // exception will be caught below |
| 413 | + throw new Exception( "Could not parse date for object {$srcRel}" ); |
| 414 | + } |
417 | 415 | } catch ( NoSuchContainerException $e ) { |
418 | | - $obj = null; |
419 | 416 | } catch ( NoSuchObjectException $e ) { |
420 | | - $obj = null; |
| 417 | + } catch ( InvalidResponseException $e ) { |
| 418 | + $stat = null; |
421 | 419 | } catch ( Exception $e ) { // some other exception? |
422 | | - $obj = null; // fail vs not exists? |
| 420 | + $stat = null; |
423 | 421 | $this->logException( $e, __METHOD__, $params ); |
424 | 422 | } |
425 | 423 | |
426 | | - if ( $obj ) { |
427 | | - // Convert "Tue, 03 Jan 2012 22:01:04 GMT" to TS_MW |
428 | | - $date = DateTime::createFromFormat( 'D, d F Y G:i:s e', $obj->last_modified ); |
429 | | - return $date ? $date->format( 'YmdHis' ) : false; // fail vs not exists? |
430 | | - } else { |
431 | | - return false; // file not found |
432 | | - } |
| 424 | + return $stat; |
433 | 425 | } |
434 | 426 | |
435 | 427 | /** |
— | — | @@ -442,20 +434,18 @@ |
443 | 435 | |
444 | 436 | $conn = $this->getConnection(); |
445 | 437 | if ( !$conn ) { |
446 | | - $status->fatal( 'backend-fail-connect' ); |
447 | | - return $status; |
| 438 | + return false; |
448 | 439 | } |
449 | 440 | |
| 441 | + $data = false; |
450 | 442 | try { |
451 | | - $container = $conn->get_container( $srcCont); |
| 443 | + $container = $conn->get_container( $srcCont ); |
452 | 444 | $obj = $container->get_object( $srcRel ); |
453 | 445 | $data = $obj->read(); |
454 | 446 | } catch ( NoSuchContainerException $e ) { |
455 | | - $data = false; |
456 | 447 | } catch ( NoSuchObjectException $e ) { |
457 | | - $data = false; |
| 448 | + } catch ( InvalidResponseException $e ) { |
458 | 449 | } catch ( Exception $e ) { // some other exception? |
459 | | - $data = false; // fail vs not exists? |
460 | 450 | $this->logException( $e, __METHOD__, $params ); |
461 | 451 | } |
462 | 452 | |
— | — | @@ -484,15 +474,14 @@ |
485 | 475 | return null; |
486 | 476 | } |
487 | 477 | |
| 478 | + $files = array(); |
488 | 479 | try { |
489 | 480 | $container = $conn->get_container( $fullCont ); |
490 | 481 | $files = $container->list_objects( $limit, $after, $dir ); |
491 | 482 | } catch ( NoSuchContainerException $e ) { |
492 | | - $files = array(); |
493 | 483 | } catch ( NoSuchObjectException $e ) { |
494 | | - $files = array(); |
| 484 | + } catch ( InvalidResponseException $e ) { |
495 | 485 | } catch ( Exception $e ) { // some other exception? |
496 | | - $files = array(); |
497 | 486 | $this->logException( $e, __METHOD__, $params ); |
498 | 487 | } |
499 | 488 | |
— | — | @@ -500,6 +489,65 @@ |
501 | 490 | } |
502 | 491 | |
503 | 492 | /** |
| 493 | + * @see FileBackend::doGetFileSha1base36() |
| 494 | + */ |
| 495 | + public function doGetFileSha1base36( array $params ) { |
| 496 | + $stat = $this->getFileStat( $params ); |
| 497 | + if ( $stat ) { |
| 498 | + return $stat['sha1']; |
| 499 | + } else { |
| 500 | + return false; |
| 501 | + } |
| 502 | + } |
| 503 | + |
| 504 | + /** |
| 505 | + * @see FileBackend::doStreamFile() |
| 506 | + */ |
| 507 | + protected function doStreamFile( array $params ) { |
| 508 | + $status = Status::newGood(); |
| 509 | + |
| 510 | + list( $srcCont, $srcRel ) = $this->resolveStoragePathReal( $params['src'] ); |
| 511 | + if ( $srcRel === null ) { |
| 512 | + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); |
| 513 | + } |
| 514 | + |
| 515 | + $conn = $this->getConnection(); |
| 516 | + if ( !$conn ) { |
| 517 | + $status->fatal( 'backend-fail-connect' ); |
| 518 | + } |
| 519 | + |
| 520 | + try { |
| 521 | + $cont = $conn->get_container( $srcCont ); |
| 522 | + $obj = $cont->get_object( $srcRel ); |
| 523 | + } catch ( NoSuchContainerException $e ) { |
| 524 | + $status->fatal( 'backend-fail-stream', $params['src'] ); |
| 525 | + return $status; |
| 526 | + } catch ( NoSuchObjectException $e ) { |
| 527 | + $status->fatal( 'backend-fail-stream', $params['src'] ); |
| 528 | + return $status; |
| 529 | + } catch ( IOException $e ) { |
| 530 | + $status->fatal( 'backend-fail-stream', $params['src'] ); |
| 531 | + return $status; |
| 532 | + } catch ( Exception $e ) { // some other exception? |
| 533 | + $status->fatal( 'backend-fail-stream', $params['src'] ); |
| 534 | + $this->logException( $e, __METHOD__, $params ); |
| 535 | + return $status; |
| 536 | + } |
| 537 | + |
| 538 | + try { |
| 539 | + $output = fopen("php://output", "w"); |
| 540 | + $obj->stream( $output ); |
| 541 | + } catch ( InvalidResponseException $e ) { |
| 542 | + $status->fatal( 'backend-fail-connect' ); |
| 543 | + } catch ( Exception $e ) { // some other exception? |
| 544 | + $status->fatal( 'backend-fail-stream', $params['src'] ); |
| 545 | + $this->logException( $e, __METHOD__, $params ); |
| 546 | + } |
| 547 | + |
| 548 | + return $status; |
| 549 | + } |
| 550 | + |
| 551 | + /** |
504 | 552 | * @see FileBackend::getLocalCopy() |
505 | 553 | */ |
506 | 554 | public function getLocalCopy( array $params ) { |
— | — | @@ -508,6 +556,11 @@ |
509 | 557 | return null; |
510 | 558 | } |
511 | 559 | |
| 560 | + $conn = $this->getConnection(); |
| 561 | + if ( !$conn ) { |
| 562 | + return null; |
| 563 | + } |
| 564 | + |
512 | 565 | // Get source file extension |
513 | 566 | $ext = FileBackend::extensionFromPath( $srcRel ); |
514 | 567 | // Create a new temporary file... |
— | — | @@ -516,11 +569,6 @@ |
517 | 570 | return null; |
518 | 571 | } |
519 | 572 | |
520 | | - $conn = $this->getConnection(); |
521 | | - if ( !$conn ) { |
522 | | - return null; |
523 | | - } |
524 | | - |
525 | 573 | try { |
526 | 574 | $cont = $conn->get_container( $srcCont ); |
527 | 575 | $obj = $cont->get_object( $srcRel ); |
— | — | @@ -531,6 +579,8 @@ |
532 | 580 | $tmpFile = null; |
533 | 581 | } catch ( IOException $e ) { |
534 | 582 | $tmpFile = null; |
| 583 | + } catch ( InvalidResponseException $e ) { |
| 584 | + $tmpFile = null; |
535 | 585 | } catch ( Exception $e ) { // some other exception? |
536 | 586 | $tmpFile = null; |
537 | 587 | $this->logException( $e, __METHOD__, $params ); |