Completed
Pull Request — master (#6473)
by Roeland
13:24
created
lib/private/Files/Config/UserMountCacheListener.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
  * Listen to hooks and update the mount cache as needed
30 30
  */
31 31
 class UserMountCacheListener {
32
-	/**
33
-	 * @var IUserMountCache
34
-	 */
35
-	private $userMountCache;
32
+    /**
33
+     * @var IUserMountCache
34
+     */
35
+    private $userMountCache;
36 36
 
37
-	/**
38
-	 * UserMountCacheListener constructor.
39
-	 *
40
-	 * @param IUserMountCache $userMountCache
41
-	 */
42
-	public function __construct(IUserMountCache $userMountCache) {
43
-		$this->userMountCache = $userMountCache;
44
-	}
37
+    /**
38
+     * UserMountCacheListener constructor.
39
+     *
40
+     * @param IUserMountCache $userMountCache
41
+     */
42
+    public function __construct(IUserMountCache $userMountCache) {
43
+        $this->userMountCache = $userMountCache;
44
+    }
45 45
 
46
-	public function listen(Manager $manager) {
47
-		$manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
-	}
46
+    public function listen(Manager $manager) {
47
+        $manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
+    }
49 49
 }
Please login to merge, or discard this patch.
lib/private/Files/Config/CachedMountInfo.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -28,114 +28,114 @@
 block discarded – undo
28 28
 use OCP\IUser;
29 29
 
30 30
 class CachedMountInfo implements ICachedMountInfo {
31
-	/**
32
-	 * @var IUser
33
-	 */
34
-	protected $user;
35
-
36
-	/**
37
-	 * @var int
38
-	 */
39
-	protected $storageId;
40
-
41
-	/**
42
-	 * @var int
43
-	 */
44
-	protected $rootId;
45
-
46
-	/**
47
-	 * @var string
48
-	 */
49
-	protected $mountPoint;
50
-
51
-	/**
52
-	 * @var int|null
53
-	 */
54
-	protected $mountId;
55
-
56
-	/**
57
-	 * @var string
58
-	 */
59
-	protected $rootInternalPath;
60
-
61
-	/**
62
-	 * CachedMountInfo constructor.
63
-	 *
64
-	 * @param IUser $user
65
-	 * @param int $storageId
66
-	 * @param int $rootId
67
-	 * @param string $mountPoint
68
-	 * @param int|null $mountId
69
-	 * @param string $rootInternalPath
70
-	 */
71
-	public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '') {
72
-		$this->user = $user;
73
-		$this->storageId = $storageId;
74
-		$this->rootId = $rootId;
75
-		$this->mountPoint = $mountPoint;
76
-		$this->mountId = $mountId;
77
-		$this->rootInternalPath = $rootInternalPath;
78
-	}
79
-
80
-	/**
81
-	 * @return IUser
82
-	 */
83
-	public function getUser() {
84
-		return $this->user;
85
-	}
86
-
87
-	/**
88
-	 * @return int the numeric storage id of the mount
89
-	 */
90
-	public function getStorageId() {
91
-		return $this->storageId;
92
-	}
93
-
94
-	/**
95
-	 * @return int the fileid of the root of the mount
96
-	 */
97
-	public function getRootId() {
98
-		return $this->rootId;
99
-	}
100
-
101
-	/**
102
-	 * @return Node the root node of the mount
103
-	 */
104
-	public function getMountPointNode() {
105
-		// TODO injection etc
106
-		Filesystem::initMountPoints($this->getUser()->getUID());
107
-		$userNode = \OC::$server->getUserFolder($this->getUser()->getUID());
108
-		$nodes = $userNode->getParent()->getById($this->getRootId());
109
-		if (count($nodes) > 0) {
110
-			return $nodes[0];
111
-		} else {
112
-			return null;
113
-		}
114
-	}
115
-
116
-	/**
117
-	 * @return string the mount point of the mount for the user
118
-	 */
119
-	public function getMountPoint() {
120
-		return $this->mountPoint;
121
-	}
122
-
123
-	/**
124
-	 * Get the id of the configured mount
125
-	 *
126
-	 * @return int|null mount id or null if not applicable
127
-	 * @since 9.1.0
128
-	 */
129
-	public function getMountId() {
130
-		return $this->mountId;
131
-	}
132
-
133
-	/**
134
-	 * Get the internal path (within the storage) of the root of the mount
135
-	 *
136
-	 * @return string
137
-	 */
138
-	public function getRootInternalPath() {
139
-		return $this->rootInternalPath;
140
-	}
31
+    /**
32
+     * @var IUser
33
+     */
34
+    protected $user;
35
+
36
+    /**
37
+     * @var int
38
+     */
39
+    protected $storageId;
40
+
41
+    /**
42
+     * @var int
43
+     */
44
+    protected $rootId;
45
+
46
+    /**
47
+     * @var string
48
+     */
49
+    protected $mountPoint;
50
+
51
+    /**
52
+     * @var int|null
53
+     */
54
+    protected $mountId;
55
+
56
+    /**
57
+     * @var string
58
+     */
59
+    protected $rootInternalPath;
60
+
61
+    /**
62
+     * CachedMountInfo constructor.
63
+     *
64
+     * @param IUser $user
65
+     * @param int $storageId
66
+     * @param int $rootId
67
+     * @param string $mountPoint
68
+     * @param int|null $mountId
69
+     * @param string $rootInternalPath
70
+     */
71
+    public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '') {
72
+        $this->user = $user;
73
+        $this->storageId = $storageId;
74
+        $this->rootId = $rootId;
75
+        $this->mountPoint = $mountPoint;
76
+        $this->mountId = $mountId;
77
+        $this->rootInternalPath = $rootInternalPath;
78
+    }
79
+
80
+    /**
81
+     * @return IUser
82
+     */
83
+    public function getUser() {
84
+        return $this->user;
85
+    }
86
+
87
+    /**
88
+     * @return int the numeric storage id of the mount
89
+     */
90
+    public function getStorageId() {
91
+        return $this->storageId;
92
+    }
93
+
94
+    /**
95
+     * @return int the fileid of the root of the mount
96
+     */
97
+    public function getRootId() {
98
+        return $this->rootId;
99
+    }
100
+
101
+    /**
102
+     * @return Node the root node of the mount
103
+     */
104
+    public function getMountPointNode() {
105
+        // TODO injection etc
106
+        Filesystem::initMountPoints($this->getUser()->getUID());
107
+        $userNode = \OC::$server->getUserFolder($this->getUser()->getUID());
108
+        $nodes = $userNode->getParent()->getById($this->getRootId());
109
+        if (count($nodes) > 0) {
110
+            return $nodes[0];
111
+        } else {
112
+            return null;
113
+        }
114
+    }
115
+
116
+    /**
117
+     * @return string the mount point of the mount for the user
118
+     */
119
+    public function getMountPoint() {
120
+        return $this->mountPoint;
121
+    }
122
+
123
+    /**
124
+     * Get the id of the configured mount
125
+     *
126
+     * @return int|null mount id or null if not applicable
127
+     * @since 9.1.0
128
+     */
129
+    public function getMountId() {
130
+        return $this->mountId;
131
+    }
132
+
133
+    /**
134
+     * Get the internal path (within the storage) of the root of the mount
135
+     *
136
+     * @return string
137
+     */
138
+    public function getRootInternalPath() {
139
+        return $this->rootInternalPath;
140
+    }
141 141
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/StorageObjectStore.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -28,63 +28,63 @@
 block discarded – undo
28 28
  * Object store that wraps a storage backend, mostly for testing purposes
29 29
  */
30 30
 class StorageObjectStore implements IObjectStore {
31
-	/** @var IStorage */
32
-	private $storage;
31
+    /** @var IStorage */
32
+    private $storage;
33 33
 
34
-	/**
35
-	 * @param IStorage $storage
36
-	 */
37
-	public function __construct(IStorage $storage) {
38
-		$this->storage = $storage;
39
-	}
34
+    /**
35
+     * @param IStorage $storage
36
+     */
37
+    public function __construct(IStorage $storage) {
38
+        $this->storage = $storage;
39
+    }
40 40
 
41
-	/**
42
-	 * @return string the container or bucket name where objects are stored
43
-	 * @since 7.0.0
44
-	 */
45
-	function getStorageId() {
46
-		$this->storage->getId();
47
-	}
41
+    /**
42
+     * @return string the container or bucket name where objects are stored
43
+     * @since 7.0.0
44
+     */
45
+    function getStorageId() {
46
+        $this->storage->getId();
47
+    }
48 48
 
49
-	/**
50
-	 * @param string $urn the unified resource name used to identify the object
51
-	 * @return resource stream with the read data
52
-	 * @throws \Exception when something goes wrong, message will be logged
53
-	 * @since 7.0.0
54
-	 */
55
-	function readObject($urn) {
56
-		$handle = $this->storage->fopen($urn, 'r');
57
-		if ($handle) {
58
-			return $handle;
59
-		} else {
60
-			throw new \Exception();
61
-		}
62
-	}
49
+    /**
50
+     * @param string $urn the unified resource name used to identify the object
51
+     * @return resource stream with the read data
52
+     * @throws \Exception when something goes wrong, message will be logged
53
+     * @since 7.0.0
54
+     */
55
+    function readObject($urn) {
56
+        $handle = $this->storage->fopen($urn, 'r');
57
+        if ($handle) {
58
+            return $handle;
59
+        } else {
60
+            throw new \Exception();
61
+        }
62
+    }
63 63
 
64
-	/**
65
-	 * @param string $urn the unified resource name used to identify the object
66
-	 * @param resource $stream stream with the data to write
67
-	 * @throws \Exception when something goes wrong, message will be logged
68
-	 * @since 7.0.0
69
-	 */
70
-	function writeObject($urn, $stream) {
71
-		$handle = $this->storage->fopen($urn, 'w');
72
-		if ($handle) {
73
-			stream_copy_to_stream($stream, $handle);
74
-			fclose($handle);
75
-		} else {
76
-			throw new \Exception();
77
-		}
78
-	}
64
+    /**
65
+     * @param string $urn the unified resource name used to identify the object
66
+     * @param resource $stream stream with the data to write
67
+     * @throws \Exception when something goes wrong, message will be logged
68
+     * @since 7.0.0
69
+     */
70
+    function writeObject($urn, $stream) {
71
+        $handle = $this->storage->fopen($urn, 'w');
72
+        if ($handle) {
73
+            stream_copy_to_stream($stream, $handle);
74
+            fclose($handle);
75
+        } else {
76
+            throw new \Exception();
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * @param string $urn the unified resource name used to identify the object
82
-	 * @return void
83
-	 * @throws \Exception when something goes wrong, message will be logged
84
-	 * @since 7.0.0
85
-	 */
86
-	function deleteObject($urn) {
87
-		$this->storage->unlink($urn);
88
-	}
80
+    /**
81
+     * @param string $urn the unified resource name used to identify the object
82
+     * @return void
83
+     * @throws \Exception when something goes wrong, message will be logged
84
+     * @since 7.0.0
85
+     */
86
+    function deleteObject($urn) {
87
+        $this->storage->unlink($urn);
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/HomeObjectStoreStorage.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -28,42 +28,42 @@
 block discarded – undo
28 28
 
29 29
 class HomeObjectStoreStorage extends ObjectStoreStorage implements \OCP\Files\IHomeStorage {
30 30
 
31
-	/**
32
-	 * The home user storage requires a user object to create a unique storage id
33
-	 * @param array $params
34
-	 */
35
-	public function __construct($params) {
36
-		if ( ! isset($params['user']) || ! $params['user'] instanceof User) {
37
-			throw new \Exception('missing user object in parameters');
38
-		}
39
-		$this->user = $params['user'];
40
-		parent::__construct($params);
41
-	}
31
+    /**
32
+     * The home user storage requires a user object to create a unique storage id
33
+     * @param array $params
34
+     */
35
+    public function __construct($params) {
36
+        if ( ! isset($params['user']) || ! $params['user'] instanceof User) {
37
+            throw new \Exception('missing user object in parameters');
38
+        }
39
+        $this->user = $params['user'];
40
+        parent::__construct($params);
41
+    }
42 42
 
43
-	public function getId () {
44
-		return 'object::user:' . $this->user->getUID();
45
-	}
43
+    public function getId () {
44
+        return 'object::user:' . $this->user->getUID();
45
+    }
46 46
 
47
-	/**
48
-	 * get the owner of a path
49
-	 *
50
-	 * @param string $path The path to get the owner
51
-	 * @return false|string uid
52
-	 */
53
-	public function getOwner($path) {
54
-		if (is_object($this->user)) {
55
-			return $this->user->getUID();
56
-		}
57
-		return false;
58
-	}
47
+    /**
48
+     * get the owner of a path
49
+     *
50
+     * @param string $path The path to get the owner
51
+     * @return false|string uid
52
+     */
53
+    public function getOwner($path) {
54
+        if (is_object($this->user)) {
55
+            return $this->user->getUID();
56
+        }
57
+        return false;
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $path, optional
62
-	 * @return \OC\User\User
63
-	 */
64
-	public function getUser($path = null) {
65
-		return $this->user;
66
-	}
60
+    /**
61
+     * @param string $path, optional
62
+     * @return \OC\User\User
63
+     */
64
+    public function getUser($path = null) {
65
+        return $this->user;
66
+    }
67 67
 
68 68
 
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/NoopScanner.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -29,52 +29,52 @@
 block discarded – undo
29 29
 
30 30
 class NoopScanner extends Scanner {
31 31
 
32
-	public function __construct(Storage $storage) {
33
-		//we don't need the storage, so do nothing here
34
-	}
32
+    public function __construct(Storage $storage) {
33
+        //we don't need the storage, so do nothing here
34
+    }
35 35
 
36
-	/**
37
-	 * scan a single file and store it in the cache
38
-	 *
39
-	 * @param string $file
40
-	 * @param int $reuseExisting
41
-	 * @param int $parentId
42
-	 * @param array|null $cacheData existing data in the cache for the file to be scanned
43
-	 * @return array an array of metadata of the scanned file
44
-	 */
45
-	public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
46
-		return array();
47
-	}
36
+    /**
37
+     * scan a single file and store it in the cache
38
+     *
39
+     * @param string $file
40
+     * @param int $reuseExisting
41
+     * @param int $parentId
42
+     * @param array|null $cacheData existing data in the cache for the file to be scanned
43
+     * @return array an array of metadata of the scanned file
44
+     */
45
+    public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
46
+        return array();
47
+    }
48 48
 
49
-	/**
50
-	 * scan a folder and all it's children
51
-	 *
52
-	 * @param string $path
53
-	 * @param bool $recursive
54
-	 * @param int $reuse
55
-	 * @return array with the meta data of the scanned file or folder
56
-	 */
57
-	public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
58
-		return array();
59
-	}
49
+    /**
50
+     * scan a folder and all it's children
51
+     *
52
+     * @param string $path
53
+     * @param bool $recursive
54
+     * @param int $reuse
55
+     * @return array with the meta data of the scanned file or folder
56
+     */
57
+    public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
58
+        return array();
59
+    }
60 60
 
61
-	/**
62
-	 * scan all the files and folders in a folder
63
-	 *
64
-	 * @param string $path
65
-	 * @param bool $recursive
66
-	 * @param int $reuse
67
-	 * @param array $folderData existing cache data for the folder to be scanned
68
-	 * @return int the size of the scanned folder or -1 if the size is unknown at this stage
69
-	 */
70
-	protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderData = null, $lock = true) {
71
-		return 0;
72
-	}
61
+    /**
62
+     * scan all the files and folders in a folder
63
+     *
64
+     * @param string $path
65
+     * @param bool $recursive
66
+     * @param int $reuse
67
+     * @param array $folderData existing cache data for the folder to be scanned
68
+     * @return int the size of the scanned folder or -1 if the size is unknown at this stage
69
+     */
70
+    protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderData = null, $lock = true) {
71
+        return 0;
72
+    }
73 73
 
74
-	/**
75
-	 * walk over any folders that are not fully scanned yet and scan them
76
-	 */
77
-	public function backgroundScan() {
78
-		//noop
79
-	}
74
+    /**
75
+     * walk over any folders that are not fully scanned yet and scan them
76
+     */
77
+    public function backgroundScan() {
78
+        //noop
79
+    }
80 80
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/Mapper.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -31,25 +31,25 @@
 block discarded – undo
31 31
  * Map a user to a bucket.
32 32
  */
33 33
 class Mapper {
34
-	/** @var IUser */
35
-	private $user;
34
+    /** @var IUser */
35
+    private $user;
36 36
 
37
-	/**
38
-	 * Mapper constructor.
39
-	 *
40
-	 * @param IUser $user
41
-	 */
42
-	public function __construct(IUser $user) {
43
-		$this->user = $user;
44
-	}
37
+    /**
38
+     * Mapper constructor.
39
+     *
40
+     * @param IUser $user
41
+     */
42
+    public function __construct(IUser $user) {
43
+        $this->user = $user;
44
+    }
45 45
 
46
-	/**
47
-	 * @param int $numBuckets
48
-	 * @return string
49
-	 */
50
-	public function getBucket($numBuckets = 64) {
51
-		$hash = md5($this->user->getUID());
52
-		$num = hexdec(substr($hash, 0, 4));
53
-		return (string)($num % $numBuckets);
54
-	}
46
+    /**
47
+     * @param int $numBuckets
48
+     * @return string
49
+     */
50
+    public function getBucket($numBuckets = 64) {
51
+        $hash = md5($this->user->getUID());
52
+        $num = hexdec(substr($hash, 0, 4));
53
+        return (string)($num % $numBuckets);
54
+    }
55 55
 }
Please login to merge, or discard this patch.
lib/private/Files/ObjectStore/S3ConnectionTrait.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -25,100 +25,100 @@
 block discarded – undo
25 25
 use Aws\S3\S3Client;
26 26
 
27 27
 trait S3ConnectionTrait {
28
-	/** @var array */
29
-	protected $params;
30
-
31
-	/** @var S3Client */
32
-	protected $connection;
33
-
34
-	/** @var string */
35
-	protected $id;
36
-
37
-	/** @var string */
38
-	protected $bucket;
39
-
40
-	/** @var int */
41
-	protected $timeout;
42
-
43
-	protected $test;
44
-
45
-	protected function parseParams($params) {
46
-		if (empty($params['key']) || empty($params['secret']) || empty($params['bucket'])) {
47
-			throw new \Exception("Access Key, Secret and Bucket have to be configured.");
48
-		}
49
-
50
-		$this->id = 'amazon::' . $params['bucket'];
51
-
52
-		$this->test = isset($params['test']);
53
-		$this->bucket = $params['bucket'];
54
-		$this->timeout = (!isset($params['timeout'])) ? 15 : $params['timeout'];
55
-		$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
56
-		$params['hostname'] = empty($params['hostname']) ? 's3.amazonaws.com' : $params['hostname'];
57
-		if (!isset($params['port']) || $params['port'] === '') {
58
-			$params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
59
-		}
60
-		$this->params = $params;
61
-	}
62
-
63
-
64
-	/**
65
-	 * Returns the connection
66
-	 *
67
-	 * @return S3Client connected client
68
-	 * @throws \Exception if connection could not be made
69
-	 */
70
-	protected function getConnection() {
71
-		if (!is_null($this->connection)) {
72
-			return $this->connection;
73
-		}
74
-
75
-		$scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https';
76
-		$base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';
77
-
78
-		$options = [
79
-			'key' => $this->params['key'],
80
-			'secret' => $this->params['secret'],
81
-			'base_url' => $base_url,
82
-			'region' => $this->params['region'],
83
-			S3Client::COMMAND_PARAMS => [
84
-				'PathStyle' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false,
85
-			]
86
-		];
87
-		if (isset($this->params['proxy'])) {
88
-			$options[S3Client::REQUEST_OPTIONS] = ['proxy' => $this->params['proxy']];
89
-		}
90
-		$this->connection = S3Client::factory($options);
91
-
92
-		if (!$this->connection->isValidBucketName($this->bucket)) {
93
-			throw new \Exception("The configured bucket name is invalid.");
94
-		}
95
-
96
-		if (!$this->connection->doesBucketExist($this->bucket)) {
97
-			try {
98
-				$this->connection->createBucket(array(
99
-					'Bucket' => $this->bucket
100
-				));
101
-				$this->connection->waitUntilBucketExists(array(
102
-					'Bucket' => $this->bucket,
103
-					'waiter.interval' => 1,
104
-					'waiter.max_attempts' => 15
105
-				));
106
-				$this->testTimeout();
107
-			} catch (S3Exception $e) {
108
-				\OCP\Util::logException('files_external', $e);
109
-				throw new \Exception('Creation of bucket failed. ' . $e->getMessage());
110
-			}
111
-		}
112
-
113
-		return $this->connection;
114
-	}
115
-
116
-	/**
117
-	 * when running the tests wait to let the buckets catch up
118
-	 */
119
-	private function testTimeout() {
120
-		if ($this->test) {
121
-			sleep($this->timeout);
122
-		}
123
-	}
28
+    /** @var array */
29
+    protected $params;
30
+
31
+    /** @var S3Client */
32
+    protected $connection;
33
+
34
+    /** @var string */
35
+    protected $id;
36
+
37
+    /** @var string */
38
+    protected $bucket;
39
+
40
+    /** @var int */
41
+    protected $timeout;
42
+
43
+    protected $test;
44
+
45
+    protected function parseParams($params) {
46
+        if (empty($params['key']) || empty($params['secret']) || empty($params['bucket'])) {
47
+            throw new \Exception("Access Key, Secret and Bucket have to be configured.");
48
+        }
49
+
50
+        $this->id = 'amazon::' . $params['bucket'];
51
+
52
+        $this->test = isset($params['test']);
53
+        $this->bucket = $params['bucket'];
54
+        $this->timeout = (!isset($params['timeout'])) ? 15 : $params['timeout'];
55
+        $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
56
+        $params['hostname'] = empty($params['hostname']) ? 's3.amazonaws.com' : $params['hostname'];
57
+        if (!isset($params['port']) || $params['port'] === '') {
58
+            $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
59
+        }
60
+        $this->params = $params;
61
+    }
62
+
63
+
64
+    /**
65
+     * Returns the connection
66
+     *
67
+     * @return S3Client connected client
68
+     * @throws \Exception if connection could not be made
69
+     */
70
+    protected function getConnection() {
71
+        if (!is_null($this->connection)) {
72
+            return $this->connection;
73
+        }
74
+
75
+        $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https';
76
+        $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';
77
+
78
+        $options = [
79
+            'key' => $this->params['key'],
80
+            'secret' => $this->params['secret'],
81
+            'base_url' => $base_url,
82
+            'region' => $this->params['region'],
83
+            S3Client::COMMAND_PARAMS => [
84
+                'PathStyle' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false,
85
+            ]
86
+        ];
87
+        if (isset($this->params['proxy'])) {
88
+            $options[S3Client::REQUEST_OPTIONS] = ['proxy' => $this->params['proxy']];
89
+        }
90
+        $this->connection = S3Client::factory($options);
91
+
92
+        if (!$this->connection->isValidBucketName($this->bucket)) {
93
+            throw new \Exception("The configured bucket name is invalid.");
94
+        }
95
+
96
+        if (!$this->connection->doesBucketExist($this->bucket)) {
97
+            try {
98
+                $this->connection->createBucket(array(
99
+                    'Bucket' => $this->bucket
100
+                ));
101
+                $this->connection->waitUntilBucketExists(array(
102
+                    'Bucket' => $this->bucket,
103
+                    'waiter.interval' => 1,
104
+                    'waiter.max_attempts' => 15
105
+                ));
106
+                $this->testTimeout();
107
+            } catch (S3Exception $e) {
108
+                \OCP\Util::logException('files_external', $e);
109
+                throw new \Exception('Creation of bucket failed. ' . $e->getMessage());
110
+            }
111
+        }
112
+
113
+        return $this->connection;
114
+    }
115
+
116
+    /**
117
+     * when running the tests wait to let the buckets catch up
118
+     */
119
+    private function testTimeout() {
120
+        if ($this->test) {
121
+            sleep($this->timeout);
122
+        }
123
+    }
124 124
 }
Please login to merge, or discard this patch.
lib/private/Files/Type/Detection.php 1 patch
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -41,287 +41,287 @@
 block discarded – undo
41 41
  * @package OC\Files\Type
42 42
  */
43 43
 class Detection implements IMimeTypeDetector {
44
-	protected $mimetypes = [];
45
-	protected $secureMimeTypes = [];
46
-
47
-	protected $mimetypeIcons = [];
48
-	/** @var string[] */
49
-	protected $mimeTypeAlias = [];
50
-
51
-	/** @var IURLGenerator */
52
-	private $urlGenerator;
53
-
54
-	/** @var string */
55
-	private $customConfigDir;
56
-
57
-	/** @var string */
58
-	private $defaultConfigDir;
59
-
60
-	/**
61
-	 * @param IURLGenerator $urlGenerator
62
-	 * @param string $customConfigDir
63
-	 * @param string $defaultConfigDir
64
-	 */
65
-	public function __construct(IURLGenerator $urlGenerator,
66
-								$customConfigDir,
67
-								$defaultConfigDir) {
68
-		$this->urlGenerator = $urlGenerator;
69
-		$this->customConfigDir = $customConfigDir;
70
-		$this->defaultConfigDir = $defaultConfigDir;
71
-	}
72
-
73
-	/**
74
-	 * Add an extension -> mimetype mapping
75
-	 *
76
-	 * $mimetype is the assumed correct mime type
77
-	 * The optional $secureMimeType is an alternative to send to send
78
-	 * to avoid potential XSS.
79
-	 *
80
-	 * @param string $extension
81
-	 * @param string $mimetype
82
-	 * @param string|null $secureMimeType
83
-	 */
84
-	public function registerType($extension,
85
-								 $mimetype,
86
-								 $secureMimeType = null) {
87
-		$this->mimetypes[$extension] = array($mimetype, $secureMimeType);
88
-		$this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype;
89
-	}
90
-
91
-	/**
92
-	 * Add an array of extension -> mimetype mappings
93
-	 *
94
-	 * The mimetype value is in itself an array where the first index is
95
-	 * the assumed correct mimetype and the second is either a secure alternative
96
-	 * or null if the correct is considered secure.
97
-	 *
98
-	 * @param array $types
99
-	 */
100
-	public function registerTypeArray($types) {
101
-		$this->mimetypes = array_merge($this->mimetypes, $types);
102
-
103
-		// Update the alternative mimetypes to avoid having to look them up each time.
104
-		foreach ($this->mimetypes as $mimeType) {
105
-			$this->secureMimeTypes[$mimeType[0]] = isset($mimeType[1]) ? $mimeType[1]: $mimeType[0];
106
-		}
107
-	}
108
-
109
-	/**
110
-	 * Add the mimetype aliases if they are not yet present
111
-	 */
112
-	private function loadAliases() {
113
-		if (!empty($this->mimeTypeAlias)) {
114
-			return;
115
-		}
116
-
117
-		$this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true);
118
-
119
-		if (file_exists($this->customConfigDir . '/mimetypealiases.json')) {
120
-			$custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypealiases.json'), true);
121
-			$this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom);
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * @return string[]
127
-	 */
128
-	public function getAllAliases() {
129
-		$this->loadAliases();
130
-		return $this->mimeTypeAlias;
131
-	}
132
-
133
-	/**
134
-	 * Add mimetype mappings if they are not yet present
135
-	 */
136
-	private function loadMappings() {
137
-		if (!empty($this->mimetypes)) {
138
-			return;
139
-		}
140
-
141
-		$mimetypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypemapping.dist.json'), true);
142
-
143
-		//Check if need to load custom mappings
144
-		if (file_exists($this->customConfigDir . '/mimetypemapping.json')) {
145
-			$custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypemapping.json'), true);
146
-			$mimetypeMapping = array_merge($mimetypeMapping, $custom);
147
-		}
148
-
149
-		$this->registerTypeArray($mimetypeMapping);
150
-	}
151
-
152
-	/**
153
-	 * @return array
154
-	 */
155
-	public function getAllMappings() {
156
-		$this->loadMappings();
157
-		return $this->mimetypes;
158
-	}
159
-
160
-	/**
161
-	 * detect mimetype only based on filename, content of file is not used
162
-	 *
163
-	 * @param string $path
164
-	 * @return string
165
-	 */
166
-	public function detectPath($path) {
167
-		$this->loadMappings();
168
-
169
-		$fileName = basename($path);
170
-
171
-		// remove leading dot on hidden files with a file extension
172
-		$fileName = ltrim($fileName, '.');
173
-
174
-		// note: leading dot doesn't qualify as extension
175
-		if (strpos($fileName, '.') > 0) {
176
-			//try to guess the type by the file extension
177
-			$extension = strtolower(strrchr($fileName, '.'));
178
-			$extension = substr($extension, 1); //remove leading .
179
-			return (isset($this->mimetypes[$extension]) && isset($this->mimetypes[$extension][0]))
180
-				? $this->mimetypes[$extension][0]
181
-				: 'application/octet-stream';
182
-		} else {
183
-			return 'application/octet-stream';
184
-		}
185
-	}
186
-
187
-	/**
188
-	 * detect mimetype based on both filename and content
189
-	 *
190
-	 * @param string $path
191
-	 * @return string
192
-	 */
193
-	public function detect($path) {
194
-		$this->loadMappings();
195
-
196
-		if (@is_dir($path)) {
197
-			// directories are easy
198
-			return "httpd/unix-directory";
199
-		}
200
-
201
-		$mimeType = $this->detectPath($path);
202
-
203
-		if ($mimeType === 'application/octet-stream' and function_exists('finfo_open')
204
-			and function_exists('finfo_file') and $finfo = finfo_open(FILEINFO_MIME)
205
-		) {
206
-			$info = @strtolower(finfo_file($finfo, $path));
207
-			finfo_close($finfo);
208
-			if ($info) {
209
-				$mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
210
-				return empty($mimeType) ? 'application/octet-stream' : $mimeType;
211
-			}
212
-
213
-		}
214
-		$isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
215
-		if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
216
-			// use mime magic extension if available
217
-			$mimeType = mime_content_type($path);
218
-		}
219
-		if (!$isWrapped and $mimeType === 'application/octet-stream' && \OC_Helper::canExecute("file")) {
220
-			// it looks like we have a 'file' command,
221
-			// lets see if it does have mime support
222
-			$path = escapeshellarg($path);
223
-			$fp = popen("file -b --mime-type $path 2>/dev/null", "r");
224
-			$reply = fgets($fp);
225
-			pclose($fp);
226
-
227
-			//trim the newline
228
-			$mimeType = trim($reply);
229
-
230
-			if (empty($mimeType)) {
231
-				$mimeType = 'application/octet-stream';
232
-			}
233
-
234
-		}
235
-		return $mimeType;
236
-	}
237
-
238
-	/**
239
-	 * detect mimetype based on the content of a string
240
-	 *
241
-	 * @param string $data
242
-	 * @return string
243
-	 */
244
-	public function detectString($data) {
245
-		if (function_exists('finfo_open') and function_exists('finfo_file')) {
246
-			$finfo = finfo_open(FILEINFO_MIME);
247
-			$info = finfo_buffer($finfo, $data);
248
-			return strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
249
-		} else {
250
-			$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
251
-			$fh = fopen($tmpFile, 'wb');
252
-			fwrite($fh, $data, 8024);
253
-			fclose($fh);
254
-			$mime = $this->detect($tmpFile);
255
-			unset($tmpFile);
256
-			return $mime;
257
-		}
258
-	}
259
-
260
-	/**
261
-	 * Get a secure mimetype that won't expose potential XSS.
262
-	 *
263
-	 * @param string $mimeType
264
-	 * @return string
265
-	 */
266
-	public function getSecureMimeType($mimeType) {
267
-		$this->loadMappings();
268
-
269
-		return isset($this->secureMimeTypes[$mimeType])
270
-			? $this->secureMimeTypes[$mimeType]
271
-			: 'application/octet-stream';
272
-	}
273
-
274
-	/**
275
-	 * Get path to the icon of a file type
276
-	 * @param string $mimetype the MIME type
277
-	 * @return string the url
278
-	 */
279
-	public function mimeTypeIcon($mimetype) {
280
-		$this->loadAliases();
281
-
282
-		while (isset($this->mimeTypeAlias[$mimetype])) {
283
-			$mimetype = $this->mimeTypeAlias[$mimetype];
284
-		}
285
-		if (isset($this->mimetypeIcons[$mimetype])) {
286
-			return $this->mimetypeIcons[$mimetype];
287
-		}
288
-
289
-		// Replace slash and backslash with a minus
290
-		$icon = str_replace('/', '-', $mimetype);
291
-		$icon = str_replace('\\', '-', $icon);
292
-
293
-		// Is it a dir?
294
-		if ($mimetype === 'dir') {
295
-			$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder.svg');
296
-			return $this->mimetypeIcons[$mimetype];
297
-		}
298
-		if ($mimetype === 'dir-shared') {
299
-			$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-shared.svg');
300
-			return $this->mimetypeIcons[$mimetype];
301
-		}
302
-		if ($mimetype === 'dir-external') {
303
-			$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-external.svg');
304
-			return $this->mimetypeIcons[$mimetype];
305
-		}
306
-
307
-		// Icon exists?
308
-		try {
309
-			$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $icon . '.svg');
310
-			return $this->mimetypeIcons[$mimetype];
311
-		} catch (\RuntimeException $e) {
312
-			// Specified image not found
313
-		}
314
-
315
-		// Try only the first part of the filetype
316
-		$mimePart = substr($icon, 0, strpos($icon, '-'));
317
-		try {
318
-			$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
319
-			return $this->mimetypeIcons[$mimetype];
320
-		} catch (\RuntimeException $e) {
321
-			// Image for the first part of the mimetype not found
322
-		}
323
-
324
-		$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg');
325
-		return $this->mimetypeIcons[$mimetype];
326
-	}
44
+    protected $mimetypes = [];
45
+    protected $secureMimeTypes = [];
46
+
47
+    protected $mimetypeIcons = [];
48
+    /** @var string[] */
49
+    protected $mimeTypeAlias = [];
50
+
51
+    /** @var IURLGenerator */
52
+    private $urlGenerator;
53
+
54
+    /** @var string */
55
+    private $customConfigDir;
56
+
57
+    /** @var string */
58
+    private $defaultConfigDir;
59
+
60
+    /**
61
+     * @param IURLGenerator $urlGenerator
62
+     * @param string $customConfigDir
63
+     * @param string $defaultConfigDir
64
+     */
65
+    public function __construct(IURLGenerator $urlGenerator,
66
+                                $customConfigDir,
67
+                                $defaultConfigDir) {
68
+        $this->urlGenerator = $urlGenerator;
69
+        $this->customConfigDir = $customConfigDir;
70
+        $this->defaultConfigDir = $defaultConfigDir;
71
+    }
72
+
73
+    /**
74
+     * Add an extension -> mimetype mapping
75
+     *
76
+     * $mimetype is the assumed correct mime type
77
+     * The optional $secureMimeType is an alternative to send to send
78
+     * to avoid potential XSS.
79
+     *
80
+     * @param string $extension
81
+     * @param string $mimetype
82
+     * @param string|null $secureMimeType
83
+     */
84
+    public function registerType($extension,
85
+                                    $mimetype,
86
+                                    $secureMimeType = null) {
87
+        $this->mimetypes[$extension] = array($mimetype, $secureMimeType);
88
+        $this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype;
89
+    }
90
+
91
+    /**
92
+     * Add an array of extension -> mimetype mappings
93
+     *
94
+     * The mimetype value is in itself an array where the first index is
95
+     * the assumed correct mimetype and the second is either a secure alternative
96
+     * or null if the correct is considered secure.
97
+     *
98
+     * @param array $types
99
+     */
100
+    public function registerTypeArray($types) {
101
+        $this->mimetypes = array_merge($this->mimetypes, $types);
102
+
103
+        // Update the alternative mimetypes to avoid having to look them up each time.
104
+        foreach ($this->mimetypes as $mimeType) {
105
+            $this->secureMimeTypes[$mimeType[0]] = isset($mimeType[1]) ? $mimeType[1]: $mimeType[0];
106
+        }
107
+    }
108
+
109
+    /**
110
+     * Add the mimetype aliases if they are not yet present
111
+     */
112
+    private function loadAliases() {
113
+        if (!empty($this->mimeTypeAlias)) {
114
+            return;
115
+        }
116
+
117
+        $this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true);
118
+
119
+        if (file_exists($this->customConfigDir . '/mimetypealiases.json')) {
120
+            $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypealiases.json'), true);
121
+            $this->mimeTypeAlias = array_merge($this->mimeTypeAlias, $custom);
122
+        }
123
+    }
124
+
125
+    /**
126
+     * @return string[]
127
+     */
128
+    public function getAllAliases() {
129
+        $this->loadAliases();
130
+        return $this->mimeTypeAlias;
131
+    }
132
+
133
+    /**
134
+     * Add mimetype mappings if they are not yet present
135
+     */
136
+    private function loadMappings() {
137
+        if (!empty($this->mimetypes)) {
138
+            return;
139
+        }
140
+
141
+        $mimetypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypemapping.dist.json'), true);
142
+
143
+        //Check if need to load custom mappings
144
+        if (file_exists($this->customConfigDir . '/mimetypemapping.json')) {
145
+            $custom = json_decode(file_get_contents($this->customConfigDir . '/mimetypemapping.json'), true);
146
+            $mimetypeMapping = array_merge($mimetypeMapping, $custom);
147
+        }
148
+
149
+        $this->registerTypeArray($mimetypeMapping);
150
+    }
151
+
152
+    /**
153
+     * @return array
154
+     */
155
+    public function getAllMappings() {
156
+        $this->loadMappings();
157
+        return $this->mimetypes;
158
+    }
159
+
160
+    /**
161
+     * detect mimetype only based on filename, content of file is not used
162
+     *
163
+     * @param string $path
164
+     * @return string
165
+     */
166
+    public function detectPath($path) {
167
+        $this->loadMappings();
168
+
169
+        $fileName = basename($path);
170
+
171
+        // remove leading dot on hidden files with a file extension
172
+        $fileName = ltrim($fileName, '.');
173
+
174
+        // note: leading dot doesn't qualify as extension
175
+        if (strpos($fileName, '.') > 0) {
176
+            //try to guess the type by the file extension
177
+            $extension = strtolower(strrchr($fileName, '.'));
178
+            $extension = substr($extension, 1); //remove leading .
179
+            return (isset($this->mimetypes[$extension]) && isset($this->mimetypes[$extension][0]))
180
+                ? $this->mimetypes[$extension][0]
181
+                : 'application/octet-stream';
182
+        } else {
183
+            return 'application/octet-stream';
184
+        }
185
+    }
186
+
187
+    /**
188
+     * detect mimetype based on both filename and content
189
+     *
190
+     * @param string $path
191
+     * @return string
192
+     */
193
+    public function detect($path) {
194
+        $this->loadMappings();
195
+
196
+        if (@is_dir($path)) {
197
+            // directories are easy
198
+            return "httpd/unix-directory";
199
+        }
200
+
201
+        $mimeType = $this->detectPath($path);
202
+
203
+        if ($mimeType === 'application/octet-stream' and function_exists('finfo_open')
204
+            and function_exists('finfo_file') and $finfo = finfo_open(FILEINFO_MIME)
205
+        ) {
206
+            $info = @strtolower(finfo_file($finfo, $path));
207
+            finfo_close($finfo);
208
+            if ($info) {
209
+                $mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
210
+                return empty($mimeType) ? 'application/octet-stream' : $mimeType;
211
+            }
212
+
213
+        }
214
+        $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
215
+        if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
216
+            // use mime magic extension if available
217
+            $mimeType = mime_content_type($path);
218
+        }
219
+        if (!$isWrapped and $mimeType === 'application/octet-stream' && \OC_Helper::canExecute("file")) {
220
+            // it looks like we have a 'file' command,
221
+            // lets see if it does have mime support
222
+            $path = escapeshellarg($path);
223
+            $fp = popen("file -b --mime-type $path 2>/dev/null", "r");
224
+            $reply = fgets($fp);
225
+            pclose($fp);
226
+
227
+            //trim the newline
228
+            $mimeType = trim($reply);
229
+
230
+            if (empty($mimeType)) {
231
+                $mimeType = 'application/octet-stream';
232
+            }
233
+
234
+        }
235
+        return $mimeType;
236
+    }
237
+
238
+    /**
239
+     * detect mimetype based on the content of a string
240
+     *
241
+     * @param string $data
242
+     * @return string
243
+     */
244
+    public function detectString($data) {
245
+        if (function_exists('finfo_open') and function_exists('finfo_file')) {
246
+            $finfo = finfo_open(FILEINFO_MIME);
247
+            $info = finfo_buffer($finfo, $data);
248
+            return strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
249
+        } else {
250
+            $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
251
+            $fh = fopen($tmpFile, 'wb');
252
+            fwrite($fh, $data, 8024);
253
+            fclose($fh);
254
+            $mime = $this->detect($tmpFile);
255
+            unset($tmpFile);
256
+            return $mime;
257
+        }
258
+    }
259
+
260
+    /**
261
+     * Get a secure mimetype that won't expose potential XSS.
262
+     *
263
+     * @param string $mimeType
264
+     * @return string
265
+     */
266
+    public function getSecureMimeType($mimeType) {
267
+        $this->loadMappings();
268
+
269
+        return isset($this->secureMimeTypes[$mimeType])
270
+            ? $this->secureMimeTypes[$mimeType]
271
+            : 'application/octet-stream';
272
+    }
273
+
274
+    /**
275
+     * Get path to the icon of a file type
276
+     * @param string $mimetype the MIME type
277
+     * @return string the url
278
+     */
279
+    public function mimeTypeIcon($mimetype) {
280
+        $this->loadAliases();
281
+
282
+        while (isset($this->mimeTypeAlias[$mimetype])) {
283
+            $mimetype = $this->mimeTypeAlias[$mimetype];
284
+        }
285
+        if (isset($this->mimetypeIcons[$mimetype])) {
286
+            return $this->mimetypeIcons[$mimetype];
287
+        }
288
+
289
+        // Replace slash and backslash with a minus
290
+        $icon = str_replace('/', '-', $mimetype);
291
+        $icon = str_replace('\\', '-', $icon);
292
+
293
+        // Is it a dir?
294
+        if ($mimetype === 'dir') {
295
+            $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder.svg');
296
+            return $this->mimetypeIcons[$mimetype];
297
+        }
298
+        if ($mimetype === 'dir-shared') {
299
+            $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-shared.svg');
300
+            return $this->mimetypeIcons[$mimetype];
301
+        }
302
+        if ($mimetype === 'dir-external') {
303
+            $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/folder-external.svg');
304
+            return $this->mimetypeIcons[$mimetype];
305
+        }
306
+
307
+        // Icon exists?
308
+        try {
309
+            $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $icon . '.svg');
310
+            return $this->mimetypeIcons[$mimetype];
311
+        } catch (\RuntimeException $e) {
312
+            // Specified image not found
313
+        }
314
+
315
+        // Try only the first part of the filetype
316
+        $mimePart = substr($icon, 0, strpos($icon, '-'));
317
+        try {
318
+            $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
319
+            return $this->mimetypeIcons[$mimetype];
320
+        } catch (\RuntimeException $e) {
321
+            // Image for the first part of the mimetype not found
322
+        }
323
+
324
+        $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg');
325
+        return $this->mimetypeIcons[$mimetype];
326
+    }
327 327
 }
Please login to merge, or discard this patch.
lib/private/Files/Type/TemplateManager.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -25,38 +25,38 @@
 block discarded – undo
25 25
 namespace OC\Files\Type;
26 26
 
27 27
 class TemplateManager {
28
-	protected $templates = array();
28
+    protected $templates = array();
29 29
 
30
-	public function registerTemplate($mimetype, $path) {
31
-		$this->templates[$mimetype] = $path;
32
-	}
30
+    public function registerTemplate($mimetype, $path) {
31
+        $this->templates[$mimetype] = $path;
32
+    }
33 33
 
34
-	/**
35
-	 * get the path of the template for a mimetype
36
-	 *
37
-	 * @param string $mimetype
38
-	 * @return string|null
39
-	 */
40
-	public function getTemplatePath($mimetype) {
41
-		if (isset($this->templates[$mimetype])) {
42
-			return $this->templates[$mimetype];
43
-		} else {
44
-			return null;
45
-		}
46
-	}
34
+    /**
35
+     * get the path of the template for a mimetype
36
+     *
37
+     * @param string $mimetype
38
+     * @return string|null
39
+     */
40
+    public function getTemplatePath($mimetype) {
41
+        if (isset($this->templates[$mimetype])) {
42
+            return $this->templates[$mimetype];
43
+        } else {
44
+            return null;
45
+        }
46
+    }
47 47
 
48
-	/**
49
-	 * get the template content for a mimetype
50
-	 *
51
-	 * @param string $mimetype
52
-	 * @return string
53
-	 */
54
-	public function getTemplate($mimetype) {
55
-		$path = $this->getTemplatePath($mimetype);
56
-		if ($path) {
57
-			return file_get_contents($path);
58
-		} else {
59
-			return '';
60
-		}
61
-	}
48
+    /**
49
+     * get the template content for a mimetype
50
+     *
51
+     * @param string $mimetype
52
+     * @return string
53
+     */
54
+    public function getTemplate($mimetype) {
55
+        $path = $this->getTemplatePath($mimetype);
56
+        if ($path) {
57
+            return file_get_contents($path);
58
+        } else {
59
+            return '';
60
+        }
61
+    }
62 62
 }
Please login to merge, or discard this patch.