コード例 #1
0
 private function deleteFiles($container)
 {
     $base = self::baseStorePath();
     $iter = $this->backend->getFileList(array('dir' => "{$base}/{$container}"));
     if ($iter) {
         foreach ($iter as $file) {
             $this->backend->quickDelete(array('src' => "{$base}/{$container}/{$file}"));
         }
         // free the directory, to avoid Permission denied under windows on rmdir
         unset($iter);
     }
     $this->backend->clean(array('dir' => "{$base}/{$container}", 'recursive' => 1));
 }
コード例 #2
0
ファイル: FileRepo.php プロジェクト: nahoj/mediawiki_ynh
	/**
	 * Call a callback function for every public file in the repository.
	 * May use either the database or the filesystem.
	 *
	 * @param $callback Array|string
	 * @return void
	 */
	protected function enumFilesInStorage( $callback ) {
		$publicRoot = $this->getZonePath( 'public' );
		$numDirs = 1 << ( $this->hashLevels * 4 );
		// Use a priori assumptions about directory structure
		// to reduce the tree height of the scanning process.
		for ( $flatIndex = 0; $flatIndex < $numDirs; $flatIndex++ ) {
			$hexString = sprintf( "%0{$this->hashLevels}x", $flatIndex );
			$path = $publicRoot;
			for ( $hexPos = 0; $hexPos < $this->hashLevels; $hexPos++ ) {
				$path .= '/' . substr( $hexString, 0, $hexPos + 1 );
			}
			$iterator = $this->backend->getFileList( array( 'dir' => $path ) );
			foreach ( $iterator as $name ) {
				// Each item returned is a public file
				call_user_func( $callback, "{$path}/{$name}" );
			}
		}
	}
コード例 #3
0
 public function getFileList(array $params)
 {
     return $this->backend->getFileList($params);
 }
コード例 #4
0
	/**
	 * @param FileBackend $src
	 * @param FileBackend $dst
	 * @param string $backendRel
	 * @return array (rel paths in $src minus those in $dst)
	 */
	protected function getListingDiffRel( FileBackend $src, FileBackend $dst, $backendRel ) {
		$srcPathsRel = $src->getFileList( array(
			'dir' => $src->getRootStoragePath() . "/$backendRel" ) );
		if ( $srcPathsRel === null ) {
			$this->error( "Could not list files in source container.", 1 ); // die
		}
		$dstPathsRel = $dst->getFileList( array(
			'dir' => $dst->getRootStoragePath() . "/$backendRel" ) );
		if ( $dstPathsRel === null ) {
			$this->error( "Could not list files in destination container.", 1 ); // die
		}
		// Get the list of destination files
		$relFilesDstSha1 = array();
		foreach ( $dstPathsRel as $dstPathRel ) {
			$relFilesDstSha1[sha1( $dstPathRel )] = 1;
		}
		unset( $dstPathsRel ); // free
		// Get the list of missing files
		$missingPathsRel = array();
		foreach ( $srcPathsRel as $srcPathRel ) {
			if ( !isset( $relFilesDstSha1[sha1( $srcPathRel )] ) ) {
				$missingPathsRel[] = $srcPathRel;
			}
		}
		unset( $srcPathsRel ); // free

		return $missingPathsRel;
	}