+ /**
+ * Removes non-existent files from a store batch.
+ */
+ function removeNonexistentFiles( $triplets ) {
+ $files = $filteredTriplets = array();
+ foreach ( $triplets as $file )
+ $files[$file[0]] = $file[0];
+
+ $result = $this->file->repo->fileExistsBatch( $files, FSRepo::FILES_ONLY );
+
+ foreach ( $triplets as $file ) {
+ if ( $result[$file[0]] ) {
+ $filteredTriplets[] = $file;
+ }
+ }
+
+ return $filteredTriplets;
+ }
+
+ /**
+ * Removes non-existent files from a cleanup batch.
+ */
+ function removeNonexistentFromCleanup( $batch ) {
+ $files = $newBatch = array();
+ $repo = $this->file->repo;
+
+ foreach ( $batch as $file ) {
+ $files[$file] = $repo->getVirtualUrl( 'deleted' ) . '/' .
+ rawurlencode( $repo->getDeletedHashPath( $file ) . $file );
+ }
+
+ $result = $repo->fileExistsBatch( $files, FSRepo::FILES_ONLY );
+
+ foreach ( $batch as $file ) {
+ if ( $result[$file] ) {
+ $newBatch[] = $file;
+ }
+ }
+
+ return $newBatch;
+ }
+