Index: trunk/phase3/includes/filerepo/RepoGroup.php |
— | — | @@ -211,14 +211,44 @@ |
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
| 215 | + /** |
| 216 | + * Find an instance of the file with this key, created at the specified time |
| 217 | + * Returns false if the file does not exist. |
| 218 | + * |
| 219 | + * @param $hash String SHA-1 |
| 220 | + * @param $options Option array, same as findFile() |
| 221 | + * @return File object or false if it is not found |
| 222 | + */ |
| 223 | + function findFileFromKey( $hash, $options = array() ) { |
| 224 | + if ( !$this->reposInitialised ) { |
| 225 | + $this->initialiseRepos(); |
| 226 | + } |
| 227 | + |
| 228 | + $file = $this->localRepo->findFileFromKey( $hash, $options ); |
| 229 | + if ( !$file ) { |
| 230 | + foreach ( $this->foreignRepos as $repo ) { |
| 231 | + $file = $repo->findFileFromKey( $hash, $options ); |
| 232 | + if ( $file ) break; |
| 233 | + } |
| 234 | + } |
| 235 | + return $file; |
| 236 | + } |
| 237 | + |
| 238 | + /** |
| 239 | + * Find all instances of files with this key |
| 240 | + * |
| 241 | + * @param $hash String SHA-1 |
| 242 | + * @return Array of File objects |
| 243 | + */ |
215 | 244 | function findBySha1( $hash ) { |
216 | 245 | if ( !$this->reposInitialised ) { |
217 | 246 | $this->initialiseRepos(); |
218 | 247 | } |
219 | 248 | |
220 | 249 | $result = $this->localRepo->findBySha1( $hash ); |
221 | | - foreach ( $this->foreignRepos as $repo ) |
| 250 | + foreach ( $this->foreignRepos as $repo ) { |
222 | 251 | $result = array_merge( $result, $repo->findBySha1( $hash ) ); |
| 252 | + } |
223 | 253 | return $result; |
224 | 254 | } |
225 | 255 | |