r110042 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110041‎ | r110042 | r110043 >
Date:01:02, 26 January 2012
Author:mglaser
Status:ok (Comments)
Tags:
Comment:
* follow up r110039
* killed doFileExists since it is not being called (thx to Aaron)
* only use blobExists where necessary
* all FileBackendTests pass
Modified paths:
  • /trunk/extensions/WindowsAzureStorage/includes/filerepo/backend/WindowsAzureFileBackend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WindowsAzureStorage/includes/filerepo/backend/WindowsAzureFileBackend.php
@@ -74,11 +74,12 @@
7575 return $status;
7676 }
7777
78 - // Check if the destination object already exists
79 - $blobExists = $this->storageClient->blobExists( $dstCont, $dstRel );
80 - if ( $blobExists && empty( $params['overwrite'] ) ) { //Blob exists _and_ should not be overridden
81 - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
82 - return $status;
 78+ if ( empty( $params['overwrite'] ) ) { //Blob should not be overridden
 79+ // Check if the destination object already exists
 80+ if ( $this->storageClient->blobExists( $dstCont, $dstRel ) ) {
 81+ $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
 82+ return $status;
 83+ }
8384 }
8485
8586 try {
@@ -106,10 +107,11 @@
107108 return $status;
108109 }
109110
110 - $blobExists = $this->storageClient->blobExists( $dstContainer, $dstDir );
111 - if ( $blobExists && empty( $params['overwrite'] ) ) { //Blob exists _and_ should not be overridden
112 - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
113 - return $status;
 111+ if ( empty( $params['overwrite'] ) ) { //Blob should not be overridden
 112+ if ( $this->storageClient->blobExists( $dstContainer, $dstDir ) ) {
 113+ $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
 114+ return $status;
 115+ }
114116 }
115117
116118 try {
@@ -165,11 +167,12 @@
166168 return $status;
167169 }
168170
169 - // Check if the destination object already exists
170 - $blobExists = $this->storageClient->blobExists( $dstCont, $dstRel );
171 - if ( $blobExists && empty( $params['overwrite'] ) ) { //Blob exists _and_ should not be overridden
172 - $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
173 - return $status;
 171+ if ( empty( $params['overwrite'] ) ) { //Blob should not be overridden
 172+ // Check if the destination object already exists
 173+ if ( $this->storageClient->blobExists( $dstCont, $dstRel ) ) {
 174+ $status->fatal( 'backend-fail-alreadyexists', $params['dst'] );
 175+ return $status;
 176+ }
174177 }
175178
176179 // Actually create the object
@@ -241,19 +244,6 @@
242245 }
243246
244247 /**
245 - * @see FileBackend::fileExists()
246 - */
247 - function doFileExists( array $params ) {
248 - list( $srcCont, $srcRel ) = $this->resolveStoragePath( $params['src'] );
249 - if ( $srcRel === null ) {
250 - return false; // invalid storage path
251 - }
252 -
253 - $exists = $this->storageClient->blobExists( $srcCont, $srcRel );
254 - return $exists;
255 - }
256 -
257 - /**
258248 * @see FileBackend::getFileList()
259249 */
260250 function getFileListInternal( $container, $dir, array $params ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110039* implemented overwrite param...mglaser00:06, 26 January 2012

Comments

#Comment by Aaron Schulz (talk | contribs)   16:49, 18 February 2012

You still should overwrite doStreamFile() and doGetFileSha1Base36(). The former should stream straight out of the store for performance. The later should use whatever metadata support Azure has to track the sha1 when an object is created (storeInternal or createInternal) as the Swift backend does. This makes the other operations faster.

#Comment by Aaron Schulz (talk | contribs)   23:25, 19 February 2012

Likewise with getFileContents() too.

Status & tagging log