From b55e9652fce3051d621356c5c87c47f44515a367 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 6 Aug 2012 10:53:44 -0700 Subject: [PATCH] [FileBackend] Fixed bogus sync-check status errors. Change-Id: Iefb3a9575e241cfdc3220301a89667d6ad96a307 --- .../backend/FileBackendMultiWrite.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/filerepo/backend/FileBackendMultiWrite.php b/includes/filerepo/backend/FileBackendMultiWrite.php index e0873d276f..e9136d5af8 100644 --- a/includes/filerepo/backend/FileBackendMultiWrite.php +++ b/includes/filerepo/backend/FileBackendMultiWrite.php @@ -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. -- 2.20.1