Index: trunk/phase3/includes/filerepo/backend/SwiftFileBackend.php |
— | — | @@ -108,13 +108,11 @@ |
109 | 109 | // (a) Check the destination container and object |
110 | 110 | try { |
111 | 111 | $dContObj = $this->getContainer( $dstCont ); |
112 | | - if ( empty( $params['overwrite'] ) ) { |
113 | | - $destObj = $dContObj->create_object( $dstRel ); |
114 | | - // Check if the object already exists (fields populated) |
115 | | - if ( $destObj->last_modified ) { |
116 | | - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
117 | | - return $status; |
118 | | - } |
| 112 | + if ( empty( $params['overwrite'] ) && |
| 113 | + $this->fileExists( array( 'src' => $params['dst'], 'latest' => 1 ) ) ) |
| 114 | + { |
| 115 | + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
| 116 | + return $status; |
119 | 117 | } |
120 | 118 | } catch ( NoSuchContainerException $e ) { |
121 | 119 | $status->fatal( 'backend-fail-create', $params['dst'] ); |
— | — | @@ -172,13 +170,11 @@ |
173 | 171 | // (a) Check the destination container and object |
174 | 172 | try { |
175 | 173 | $dContObj = $this->getContainer( $dstCont ); |
176 | | - if ( empty( $params['overwrite'] ) ) { |
177 | | - $destObj = $dContObj->create_object( $dstRel ); |
178 | | - // Check if the object already exists (fields populated) |
179 | | - if ( $destObj->last_modified ) { |
180 | | - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
181 | | - return $status; |
182 | | - } |
| 174 | + if ( empty( $params['overwrite'] ) && |
| 175 | + $this->fileExists( array( 'src' => $params['dst'], 'latest' => 1 ) ) ) |
| 176 | + { |
| 177 | + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
| 178 | + return $status; |
183 | 179 | } |
184 | 180 | } catch ( NoSuchContainerException $e ) { |
185 | 181 | $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
— | — | @@ -249,13 +245,11 @@ |
250 | 246 | try { |
251 | 247 | $sContObj = $this->getContainer( $srcCont ); |
252 | 248 | $dContObj = $this->getContainer( $dstCont ); |
253 | | - if ( empty( $params['overwrite'] ) ) { |
254 | | - $destObj = $dContObj->create_object( $dstRel ); |
255 | | - // Check if the object already exists (fields populated) |
256 | | - if ( $destObj->last_modified ) { |
257 | | - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
258 | | - return $status; |
259 | | - } |
| 249 | + if ( empty( $params['overwrite'] ) && |
| 250 | + $this->fileExists( array( 'src' => $params['dst'], 'latest' => 1 ) ) ) |
| 251 | + { |
| 252 | + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); |
| 253 | + return $status; |
260 | 254 | } |
261 | 255 | } catch ( NoSuchContainerException $e ) { |
262 | 256 | $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); |
— | — | @@ -478,13 +472,16 @@ |
479 | 473 | return false; // invalid storage path |
480 | 474 | } |
481 | 475 | |
| 476 | + if ( !$this->fileExists( $params ) ) { |
| 477 | + return null; |
| 478 | + } |
| 479 | + |
482 | 480 | $data = false; |
483 | 481 | try { |
484 | | - $container = $this->getContainer( $srcCont ); |
485 | | - $obj = $container->get_object( $srcRel ); |
| 482 | + $sContObj = $this->getContainer( $srcCont ); |
| 483 | + $obj = new CF_Object( $sContObj, $srcRel, false, false ); // skip HEAD request |
486 | 484 | $data = $obj->read( $this->headersFromParams( $params ) ); |
487 | 485 | } catch ( NoSuchContainerException $e ) { |
488 | | - } catch ( NoSuchObjectException $e ) { |
489 | 486 | } catch ( InvalidResponseException $e ) { |
490 | 487 | } catch ( Exception $e ) { // some other exception? |
491 | 488 | $this->logException( $e, __METHOD__, $params ); |
— | — | @@ -587,10 +584,14 @@ |
588 | 585 | return null; |
589 | 586 | } |
590 | 587 | |
| 588 | + if ( !$this->fileExists( $params ) ) { |
| 589 | + return null; |
| 590 | + } |
| 591 | + |
591 | 592 | $tmpFile = null; |
592 | 593 | try { |
593 | | - $cont = $this->getContainer( $srcCont ); |
594 | | - $obj = $cont->get_object( $srcRel ); |
| 594 | + $sContObj = $this->getContainer( $srcCont ); |
| 595 | + $obj = new CF_Object( $sContObj, $srcRel, false, false ); // skip HEAD |
595 | 596 | // Get source file extension |
596 | 597 | $ext = FileBackend::extensionFromPath( $srcRel ); |
597 | 598 | // Create a new temporary file... |
— | — | @@ -606,8 +607,6 @@ |
607 | 608 | } |
608 | 609 | } catch ( NoSuchContainerException $e ) { |
609 | 610 | $tmpFile = null; |
610 | | - } catch ( NoSuchObjectException $e ) { |
611 | | - $tmpFile = null; |
612 | 611 | } catch ( InvalidResponseException $e ) { |
613 | 612 | $tmpFile = null; |
614 | 613 | } catch ( Exception $e ) { // some other exception? |