[FileBackend] Fixed bogus sync-check status errors.
authorAaron <aschulz@wikimedia.org>
Mon, 6 Aug 2012 17:53:44 +0000 (10:53 -0700)
committerAaron <aschulz@wikimedia.org>
Mon, 6 Aug 2012 17:53:44 +0000 (10:53 -0700)
Change-Id: Iefb3a9575e241cfdc3220301a89667d6ad96a307

includes/filerepo/backend/FileBackendMultiWrite.php

index e0873d2..e9136d5 100644 (file)
@@ -140,7 +140,7 @@ class FileBackendMultiWrite extends FileBackend {
                // Clear any cache entries (after locks acquired)
                $this->clearCache();
                // Do a consistency check to see if the backends agree
-               $status->merge( $this->consistencyCheck( array_merge( $paths['sh'], $paths['ex'] ) ) );
+               $status->merge( $this->consistencyCheck( $this->fileStoragePathsForOps( $ops ) ) );
                if ( !$status->isOK() ) {
                        return $status; // abort
                }
@@ -234,6 +234,28 @@ class FileBackendMultiWrite extends FileBackend {
                return $status;
        }
 
+       /**
+        * Get a list of file storage paths to read or write for a list of operations
+        *
+        * @param $ops Array Same format as doOperations()
+        * @return Array List of storage paths to files (does not include directories)
+        */
+       protected function fileStoragePathsForOps( array $ops ) {
+               $paths = array();
+               foreach ( $ops as $op ) {
+                       if ( isset( $op['src'] ) ) {
+                               $paths[] = $op['src'];
+                       }
+                       if ( isset( $op['srcs'] ) ) {
+                               $paths = array_merge( $paths, $op['srcs'] );
+                       }
+                       if ( isset( $op['dst'] ) ) {
+                               $paths[] = $op['dst'];
+                       }
+               }
+               return array_unique( $paths );
+       }
+
        /**
         * Substitute the backend name in storage path parameters
         * for a set of operations with that of a given internal backend.