summaryrefslogtreecommitdiff
path: root/includes/filerepo/FSRepo.php
blob: 9c8d85dc2ad3cadc41d8395f250d94449e6653bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
 * A repository for files accessible via the local filesystem.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @file
 * @ingroup FileRepo
 */

/**
 * A repository for files accessible via the local filesystem.
 * Does not support database access or registration.
 * 
 * This is a mostly a legacy class. New uses should not be added.
 * 
 * @ingroup FileRepo
 * @deprecated since 1.19
 */
class FSRepo extends FileRepo {

	/**
	 * @param $info array
	 * @throws MWException
	 */
	function __construct( array $info ) {
		if ( !isset( $info['backend'] ) ) {
			// B/C settings...
			$directory = $info['directory'];
			$deletedDir = isset( $info['deletedDir'] )
				? $info['deletedDir']
				: false;
			$thumbDir = isset( $info['thumbDir'] )
				? $info['thumbDir']
				: "{$directory}/thumb";
			$fileMode = isset( $info['fileMode'] )
				? $info['fileMode']
				: 0644;

			$repoName = $info['name'];
			// Get the FS backend configuration
			$backend = new FSFileBackend( array(
				'name'           => $info['name'] . '-backend',
				'lockManager'    => 'fsLockManager',
				'containerPaths' => array(
					"{$repoName}-public"  => "{$directory}",
					"{$repoName}-temp"    => "{$directory}/temp",
					"{$repoName}-thumb"   => $thumbDir,
					"{$repoName}-deleted" => $deletedDir
				),
				'fileMode'       => $fileMode,
			) );
			// Update repo config to use this backend
			$info['backend'] = $backend;
		}

		parent::__construct( $info );

		if ( !( $this->backend instanceof FSFileBackend ) ) {
			throw new MWException( "FSRepo only supports FSFileBackend." );
		}
	}
}