Passed
Push — master ( da9ad9...c724eb )
by Roeland
13:33 queued 01:55
created
apps/dav/lib/Capabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
 use OCP\Capabilities\ICapability;
26 26
 
27 27
 class Capabilities implements ICapability {
28
-	public function getCapabilities() {
29
-		return [
30
-			'dav' => [
31
-				'chunking' => '1.0',
32
-			]
33
-		];
34
-	}
28
+    public function getCapabilities() {
29
+        return [
30
+            'dav' => [
31
+                'chunking' => '1.0',
32
+            ]
33
+        ];
34
+    }
35 35
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/FutureFile.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -36,87 +36,87 @@
 block discarded – undo
36 36
  */
37 37
 class FutureFile implements \Sabre\DAV\IFile {
38 38
 
39
-	/** @var Directory */
40
-	private $root;
41
-	/** @var string */
42
-	private $name;
39
+    /** @var Directory */
40
+    private $root;
41
+    /** @var string */
42
+    private $name;
43 43
 
44
-	/**
45
-	 * @param Directory $root
46
-	 * @param string $name
47
-	 */
48
-	public function __construct(Directory $root, $name) {
49
-		$this->root = $root;
50
-		$this->name = $name;
51
-	}
44
+    /**
45
+     * @param Directory $root
46
+     * @param string $name
47
+     */
48
+    public function __construct(Directory $root, $name) {
49
+        $this->root = $root;
50
+        $this->name = $name;
51
+    }
52 52
 
53
-	/**
54
-	 * @inheritdoc
55
-	 */
56
-	public function put($data) {
57
-		throw new Forbidden('Permission denied to put into this file');
58
-	}
53
+    /**
54
+     * @inheritdoc
55
+     */
56
+    public function put($data) {
57
+        throw new Forbidden('Permission denied to put into this file');
58
+    }
59 59
 
60
-	/**
61
-	 * @inheritdoc
62
-	 */
63
-	public function get() {
64
-		$nodes = $this->root->getChildren();
65
-		return AssemblyStream::wrap($nodes);
66
-	}
60
+    /**
61
+     * @inheritdoc
62
+     */
63
+    public function get() {
64
+        $nodes = $this->root->getChildren();
65
+        return AssemblyStream::wrap($nodes);
66
+    }
67 67
 
68
-	/**
69
-	 * @inheritdoc
70
-	 */
71
-	public function getContentType() {
72
-		return 'application/octet-stream';
73
-	}
68
+    /**
69
+     * @inheritdoc
70
+     */
71
+    public function getContentType() {
72
+        return 'application/octet-stream';
73
+    }
74 74
 
75
-	/**
76
-	 * @inheritdoc
77
-	 */
78
-	public function getETag() {
79
-		return $this->root->getETag();
80
-	}
75
+    /**
76
+     * @inheritdoc
77
+     */
78
+    public function getETag() {
79
+        return $this->root->getETag();
80
+    }
81 81
 
82
-	/**
83
-	 * @inheritdoc
84
-	 */
85
-	public function getSize() {
86
-		$children = $this->root->getChildren();
87
-		$sizes = array_map(function ($node) {
88
-			/** @var IFile $node */
89
-			return $node->getSize();
90
-		}, $children);
82
+    /**
83
+     * @inheritdoc
84
+     */
85
+    public function getSize() {
86
+        $children = $this->root->getChildren();
87
+        $sizes = array_map(function ($node) {
88
+            /** @var IFile $node */
89
+            return $node->getSize();
90
+        }, $children);
91 91
 
92
-		return array_sum($sizes);
93
-	}
92
+        return array_sum($sizes);
93
+    }
94 94
 
95
-	/**
96
-	 * @inheritdoc
97
-	 */
98
-	public function delete() {
99
-		$this->root->delete();
100
-	}
95
+    /**
96
+     * @inheritdoc
97
+     */
98
+    public function delete() {
99
+        $this->root->delete();
100
+    }
101 101
 
102
-	/**
103
-	 * @inheritdoc
104
-	 */
105
-	public function getName() {
106
-		return $this->name;
107
-	}
102
+    /**
103
+     * @inheritdoc
104
+     */
105
+    public function getName() {
106
+        return $this->name;
107
+    }
108 108
 
109
-	/**
110
-	 * @inheritdoc
111
-	 */
112
-	public function setName($name) {
113
-		throw new Forbidden('Permission denied to rename this file');
114
-	}
109
+    /**
110
+     * @inheritdoc
111
+     */
112
+    public function setName($name) {
113
+        throw new Forbidden('Permission denied to rename this file');
114
+    }
115 115
 
116
-	/**
117
-	 * @inheritdoc
118
-	 */
119
-	public function getLastModified() {
120
-		return $this->root->getLastModified();
121
-	}
116
+    /**
117
+     * @inheritdoc
118
+     */
119
+    public function getLastModified() {
120
+        return $this->root->getLastModified();
121
+    }
122 122
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/DeleteOrphanedSharesJob.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@
 block discarded – undo
31 31
  */
32 32
 class DeleteOrphanedSharesJob extends TimedJob {
33 33
 
34
-	/**
35
-	 * Default interval in minutes
36
-	 *
37
-	 * @var int $defaultIntervalMin
38
-	 **/
39
-	protected $defaultIntervalMin = 15;
34
+    /**
35
+     * Default interval in minutes
36
+     *
37
+     * @var int $defaultIntervalMin
38
+     **/
39
+    protected $defaultIntervalMin = 15;
40 40
 
41
-	/**
42
-	 * sets the correct interval for this timed job
43
-	 */
44
-	public function __construct() {
45
-		$this->interval = $this->defaultIntervalMin * 60;
46
-	}
41
+    /**
42
+     * sets the correct interval for this timed job
43
+     */
44
+    public function __construct() {
45
+        $this->interval = $this->defaultIntervalMin * 60;
46
+    }
47 47
 
48
-	/**
49
-	 * Makes the background job do its work
50
-	 *
51
-	 * @param array $argument unused argument
52
-	 */
53
-	public function run($argument) {
54
-		$connection = \OC::$server->getDatabaseConnection();
55
-		$logger = \OC::$server->getLogger();
48
+    /**
49
+     * Makes the background job do its work
50
+     *
51
+     * @param array $argument unused argument
52
+     */
53
+    public function run($argument) {
54
+        $connection = \OC::$server->getDatabaseConnection();
55
+        $logger = \OC::$server->getLogger();
56 56
 
57
-		$sql =
58
-			'DELETE FROM `*PREFIX*share` ' .
59
-			'WHERE `item_type` in (\'file\', \'folder\') ' .
60
-			'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
57
+        $sql =
58
+            'DELETE FROM `*PREFIX*share` ' .
59
+            'WHERE `item_type` in (\'file\', \'folder\') ' .
60
+            'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
61 61
 
62
-		$deletedEntries = $connection->executeUpdate($sql);
63
-		$logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
-	}
62
+        $deletedEntries = $connection->executeUpdate($sql);
63
+        $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
+    }
65 65
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Migration/SetPasswordColumn.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -36,60 +36,60 @@
 block discarded – undo
36 36
  */
37 37
 class SetPasswordColumn implements IRepairStep {
38 38
 
39
-	/** @var IDBConnection */
40
-	private $connection;
39
+    /** @var IDBConnection */
40
+    private $connection;
41 41
 
42
-	/** @var  IConfig */
43
-	private $config;
42
+    /** @var  IConfig */
43
+    private $config;
44 44
 
45 45
 
46
-	public function __construct(IDBConnection $connection, IConfig $config) {
47
-		$this->connection = $connection;
48
-		$this->config = $config;
49
-	}
46
+    public function __construct(IDBConnection $connection, IConfig $config) {
47
+        $this->connection = $connection;
48
+        $this->config = $config;
49
+    }
50 50
 
51
-	/**
52
-	 * Returns the step's name
53
-	 *
54
-	 * @return string
55
-	 * @since 9.1.0
56
-	 */
57
-	public function getName() {
58
-		return 'Copy the share password into the dedicated column';
59
-	}
51
+    /**
52
+     * Returns the step's name
53
+     *
54
+     * @return string
55
+     * @since 9.1.0
56
+     */
57
+    public function getName() {
58
+        return 'Copy the share password into the dedicated column';
59
+    }
60 60
 
61
-	/**
62
-	 * @param IOutput $output
63
-	 */
64
-	public function run(IOutput $output) {
65
-		if (!$this->shouldRun()) {
66
-			return;
67
-		}
61
+    /**
62
+     * @param IOutput $output
63
+     */
64
+    public function run(IOutput $output) {
65
+        if (!$this->shouldRun()) {
66
+            return;
67
+        }
68 68
 
69
-		$query = $this->connection->getQueryBuilder();
70
-		$query
71
-			->update('share')
72
-			->set('password', 'share_with')
73
-			->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
74
-			->andWhere($query->expr()->isNotNull('share_with'));
75
-		$result = $query->execute();
69
+        $query = $this->connection->getQueryBuilder();
70
+        $query
71
+            ->update('share')
72
+            ->set('password', 'share_with')
73
+            ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
74
+            ->andWhere($query->expr()->isNotNull('share_with'));
75
+        $result = $query->execute();
76 76
 
77
-		if ($result === 0) {
78
-			// No link updated, no need to run the second query
79
-			return;
80
-		}
77
+        if ($result === 0) {
78
+            // No link updated, no need to run the second query
79
+            return;
80
+        }
81 81
 
82
-		$clearQuery = $this->connection->getQueryBuilder();
83
-		$clearQuery
84
-			->update('share')
85
-			->set('share_with', $clearQuery->createNamedParameter(null))
86
-			->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
82
+        $clearQuery = $this->connection->getQueryBuilder();
83
+        $clearQuery
84
+            ->update('share')
85
+            ->set('share_with', $clearQuery->createNamedParameter(null))
86
+            ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
87 87
 
88
-		$clearQuery->execute();
89
-	}
88
+        $clearQuery->execute();
89
+    }
90 90
 
91
-	protected function shouldRun() {
92
-		$appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
93
-		return version_compare($appVersion, '1.4.0', '<');
94
-	}
91
+    protected function shouldRun() {
92
+        $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
93
+        return version_compare($appVersion, '1.4.0', '<');
94
+    }
95 95
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Export.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@
 block discarded – undo
29 29
 use Symfony\Component\Console\Output\OutputInterface;
30 30
 
31 31
 class Export extends ListCommand {
32
-	protected function configure() {
33
-		$this
34
-			->setName('files_external:export')
35
-			->setDescription('Export mount configurations')
36
-			->addArgument(
37
-				'user_id',
38
-				InputArgument::OPTIONAL,
39
-				'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
40
-			)->addOption(
41
-				'all',
42
-				'a',
43
-				InputOption::VALUE_NONE,
44
-				'show both system wide mounts and all personal mounts'
45
-			);
46
-	}
32
+    protected function configure() {
33
+        $this
34
+            ->setName('files_external:export')
35
+            ->setDescription('Export mount configurations')
36
+            ->addArgument(
37
+                'user_id',
38
+                InputArgument::OPTIONAL,
39
+                'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
40
+            )->addOption(
41
+                'all',
42
+                'a',
43
+                InputOption::VALUE_NONE,
44
+                'show both system wide mounts and all personal mounts'
45
+            );
46
+    }
47 47
 
48
-	protected function execute(InputInterface $input, OutputInterface $output) {
49
-		$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
50
-		$listInput = new ArrayInput([], $listCommand->getDefinition());
51
-		$listInput->setArgument('user_id', $input->getArgument('user_id'));
52
-		$listInput->setOption('all', $input->getOption('all'));
53
-		$listInput->setOption('output', 'json_pretty');
54
-		$listInput->setOption('show-password', true);
55
-		$listInput->setOption('full', true);
56
-		$listCommand->execute($listInput, $output);
57
-	}
48
+    protected function execute(InputInterface $input, OutputInterface $output) {
49
+        $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
50
+        $listInput = new ArrayInput([], $listCommand->getDefinition());
51
+        $listInput->setArgument('user_id', $input->getArgument('user_id'));
52
+        $listInput->setOption('all', $input->getOption('all'));
53
+        $listInput->setOption('output', 'json_pretty');
54
+        $listInput->setOption('show-password', true);
55
+        $listInput->setOption('full', true);
56
+        $listCommand->execute($listInput, $output);
57
+    }
58 58
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Verify.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -37,108 +37,108 @@
 block discarded – undo
37 37
 use Symfony\Component\Console\Output\OutputInterface;
38 38
 
39 39
 class Verify extends Base {
40
-	/**
41
-	 * @var GlobalStoragesService
42
-	 */
43
-	protected $globalService;
40
+    /**
41
+     * @var GlobalStoragesService
42
+     */
43
+    protected $globalService;
44 44
 
45
-	public function __construct(GlobalStoragesService $globalService) {
46
-		parent::__construct();
47
-		$this->globalService = $globalService;
48
-	}
45
+    public function __construct(GlobalStoragesService $globalService) {
46
+        parent::__construct();
47
+        $this->globalService = $globalService;
48
+    }
49 49
 
50
-	protected function configure() {
51
-		$this
52
-			->setName('files_external:verify')
53
-			->setDescription('Verify mount configuration')
54
-			->addArgument(
55
-				'mount_id',
56
-				InputArgument::REQUIRED,
57
-				'The id of the mount to check'
58
-			)->addOption(
59
-				'config',
60
-				'c',
61
-				InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
62
-				'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails'
63
-			);
64
-		parent::configure();
65
-	}
50
+    protected function configure() {
51
+        $this
52
+            ->setName('files_external:verify')
53
+            ->setDescription('Verify mount configuration')
54
+            ->addArgument(
55
+                'mount_id',
56
+                InputArgument::REQUIRED,
57
+                'The id of the mount to check'
58
+            )->addOption(
59
+                'config',
60
+                'c',
61
+                InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
62
+                'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails'
63
+            );
64
+        parent::configure();
65
+    }
66 66
 
67
-	protected function execute(InputInterface $input, OutputInterface $output) {
68
-		$mountId = $input->getArgument('mount_id');
69
-		$configInput = $input->getOption('config');
67
+    protected function execute(InputInterface $input, OutputInterface $output) {
68
+        $mountId = $input->getArgument('mount_id');
69
+        $configInput = $input->getOption('config');
70 70
 
71
-		try {
72
-			$mount = $this->globalService->getStorage($mountId);
73
-		} catch (NotFoundException $e) {
74
-			$output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
75
-			return 404;
76
-		}
71
+        try {
72
+            $mount = $this->globalService->getStorage($mountId);
73
+        } catch (NotFoundException $e) {
74
+            $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>');
75
+            return 404;
76
+        }
77 77
 
78
-		$this->updateStorageStatus($mount, $configInput, $output);
78
+        $this->updateStorageStatus($mount, $configInput, $output);
79 79
 
80
-		$this->writeArrayInOutputFormat($input, $output, [
81
-			'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()),
82
-			'code' => $mount->getStatus(),
83
-			'message' => $mount->getStatusMessage()
84
-		]);
85
-	}
80
+        $this->writeArrayInOutputFormat($input, $output, [
81
+            'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()),
82
+            'code' => $mount->getStatus(),
83
+            'message' => $mount->getStatusMessage()
84
+        ]);
85
+    }
86 86
 
87
-	private function manipulateStorageConfig(StorageConfig $storage) {
88
-		/** @var AuthMechanism */
89
-		$authMechanism = $storage->getAuthMechanism();
90
-		$authMechanism->manipulateStorageConfig($storage);
91
-		/** @var Backend */
92
-		$backend = $storage->getBackend();
93
-		$backend->manipulateStorageConfig($storage);
94
-	}
87
+    private function manipulateStorageConfig(StorageConfig $storage) {
88
+        /** @var AuthMechanism */
89
+        $authMechanism = $storage->getAuthMechanism();
90
+        $authMechanism->manipulateStorageConfig($storage);
91
+        /** @var Backend */
92
+        $backend = $storage->getBackend();
93
+        $backend->manipulateStorageConfig($storage);
94
+    }
95 95
 
96
-	private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) {
97
-		try {
98
-			try {
99
-				$this->manipulateStorageConfig($storage);
100
-			} catch (InsufficientDataForMeaningfulAnswerException $e) {
101
-				if (count($configInput) === 0) { // extra config options might solve the error
102
-					throw $e;
103
-				}
104
-			}
96
+    private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) {
97
+        try {
98
+            try {
99
+                $this->manipulateStorageConfig($storage);
100
+            } catch (InsufficientDataForMeaningfulAnswerException $e) {
101
+                if (count($configInput) === 0) { // extra config options might solve the error
102
+                    throw $e;
103
+                }
104
+            }
105 105
 
106
-			foreach ($configInput as $configOption) {
107
-				if (!strpos($configOption, '=')) {
108
-					$output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
109
-					return;
110
-				}
111
-				list($key, $value) = explode('=', $configOption, 2);
112
-				$storage->setBackendOption($key, $value);
113
-			}
106
+            foreach ($configInput as $configOption) {
107
+                if (!strpos($configOption, '=')) {
108
+                    $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>');
109
+                    return;
110
+                }
111
+                list($key, $value) = explode('=', $configOption, 2);
112
+                $storage->setBackendOption($key, $value);
113
+            }
114 114
 
115
-			/** @var Backend */
116
-			$backend = $storage->getBackend();
117
-			// update status (can be time-consuming)
118
-			$storage->setStatus(
119
-				\OC_Mount_Config::getBackendStatus(
120
-					$backend->getStorageClass(),
121
-					$storage->getBackendOptions(),
122
-					false
123
-				)
124
-			);
125
-		} catch (InsufficientDataForMeaningfulAnswerException $e) {
126
-			$status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
127
-			$storage->setStatus(
128
-				$status,
129
-				$e->getMessage()
130
-			);
131
-		} catch (StorageNotAvailableException $e) {
132
-			$storage->setStatus(
133
-				$e->getCode(),
134
-				$e->getMessage()
135
-			);
136
-		} catch (\Exception $e) {
137
-			// FIXME: convert storage exceptions to StorageNotAvailableException
138
-			$storage->setStatus(
139
-				StorageNotAvailableException::STATUS_ERROR,
140
-				get_class($e) . ': ' . $e->getMessage()
141
-			);
142
-		}
143
-	}
115
+            /** @var Backend */
116
+            $backend = $storage->getBackend();
117
+            // update status (can be time-consuming)
118
+            $storage->setStatus(
119
+                \OC_Mount_Config::getBackendStatus(
120
+                    $backend->getStorageClass(),
121
+                    $storage->getBackendOptions(),
122
+                    false
123
+                )
124
+            );
125
+        } catch (InsufficientDataForMeaningfulAnswerException $e) {
126
+            $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE;
127
+            $storage->setStatus(
128
+                $status,
129
+                $e->getMessage()
130
+            );
131
+        } catch (StorageNotAvailableException $e) {
132
+            $storage->setStatus(
133
+                $e->getCode(),
134
+                $e->getMessage()
135
+            );
136
+        } catch (\Exception $e) {
137
+            // FIXME: convert storage exceptions to StorageNotAvailableException
138
+            $storage->setStatus(
139
+                StorageNotAvailableException::STATUS_ERROR,
140
+                get_class($e) . ': ' . $e->getMessage()
141
+            );
142
+        }
143
+    }
144 144
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/UserGlobalStoragesService.php 1 patch
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -33,167 +33,167 @@
 block discarded – undo
33 33
  * Read-only access available, attempting to write will throw DomainException
34 34
  */
35 35
 class UserGlobalStoragesService extends GlobalStoragesService {
36
-	use UserTrait;
37
-
38
-	/** @var IGroupManager */
39
-	protected $groupManager;
40
-
41
-	/**
42
-	 * @param BackendService $backendService
43
-	 * @param DBConfigService $dbConfig
44
-	 * @param IUserSession $userSession
45
-	 * @param IGroupManager $groupManager
46
-	 * @param IUserMountCache $userMountCache
47
-	 */
48
-	public function __construct(
49
-		BackendService $backendService,
50
-		DBConfigService $dbConfig,
51
-		IUserSession $userSession,
52
-		IGroupManager $groupManager,
53
-		IUserMountCache $userMountCache
54
-	) {
55
-		parent::__construct($backendService, $dbConfig, $userMountCache);
56
-		$this->userSession = $userSession;
57
-		$this->groupManager = $groupManager;
58
-	}
59
-
60
-	/**
61
-	 * Replace config hash ID with real IDs, for migrating legacy storages
62
-	 *
63
-	 * @param StorageConfig[] $storages Storages with real IDs
64
-	 * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs
65
-	 */
66
-	protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) {
67
-		// as a read-only view, storage IDs don't need to be real
68
-		foreach ($storagesWithConfigHash as $storage) {
69
-			$storages[$storage->getId()] = $storage;
70
-		}
71
-	}
72
-
73
-	protected function readDBConfig() {
74
-		$userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
75
-		$globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
76
-		$groups = $this->groupManager->getUserGroupIds($this->getUser());
77
-		if (is_array($groups) && count($groups) !== 0) {
78
-			$groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups);
79
-		} else {
80
-			$groupMounts = [];
81
-		}
82
-		return array_merge($userMounts, $groupMounts, $globalMounts);
83
-	}
84
-
85
-	public function addStorage(StorageConfig $newStorage) {
86
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
87
-	}
88
-
89
-	public function updateStorage(StorageConfig $updatedStorage) {
90
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
91
-	}
92
-
93
-	/**
94
-	 * @param integer $id
95
-	 */
96
-	public function removeStorage($id) {
97
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
98
-	}
99
-
100
-	/**
101
-	 * Get unique storages, in case two are defined with the same mountpoint
102
-	 * Higher priority storages take precedence
103
-	 *
104
-	 * @return StorageConfig[]
105
-	 */
106
-	public function getUniqueStorages() {
107
-		$storages = $this->getStorages();
108
-
109
-		$storagesByMountpoint = [];
110
-		foreach ($storages as $storage) {
111
-			$storagesByMountpoint[$storage->getMountPoint()][] = $storage;
112
-		}
113
-
114
-		$result = [];
115
-		foreach ($storagesByMountpoint as $storageList) {
116
-			$storage = array_reduce($storageList, function ($carry, $item) {
117
-				if (isset($carry)) {
118
-					$carryPriorityType = $this->getPriorityType($carry);
119
-					$itemPriorityType = $this->getPriorityType($item);
120
-					if ($carryPriorityType > $itemPriorityType) {
121
-						return $carry;
122
-					} elseif ($carryPriorityType === $itemPriorityType) {
123
-						if ($carry->getPriority() > $item->getPriority()) {
124
-							return $carry;
125
-						}
126
-					}
127
-				}
128
-				return $item;
129
-			});
130
-			$result[$storage->getID()] = $storage;
131
-		}
132
-
133
-		return $result;
134
-	}
135
-
136
-	/**
137
-	 * Get a priority 'type', where a bigger number means higher priority
138
-	 * user applicable > group applicable > 'all'
139
-	 *
140
-	 * @param StorageConfig $storage
141
-	 * @return int
142
-	 */
143
-	protected function getPriorityType(StorageConfig $storage) {
144
-		$applicableUsers = $storage->getApplicableUsers();
145
-		$applicableGroups = $storage->getApplicableGroups();
146
-
147
-		if ($applicableUsers && $applicableUsers[0] !== 'all') {
148
-			return 2;
149
-		}
150
-		if ($applicableGroups) {
151
-			return 1;
152
-		}
153
-		return 0;
154
-	}
155
-
156
-	protected function isApplicable(StorageConfig $config) {
157
-		$applicableUsers = $config->getApplicableUsers();
158
-		$applicableGroups = $config->getApplicableGroups();
159
-
160
-		if (count($applicableUsers) === 0 && count($applicableGroups) === 0) {
161
-			return true;
162
-		}
163
-		if (in_array($this->getUser()->getUID(), $applicableUsers, true)) {
164
-			return true;
165
-		}
166
-		$groupIds = $this->groupManager->getUserGroupIds($this->getUser());
167
-		foreach ($groupIds as $groupId) {
168
-			if (in_array($groupId, $applicableGroups, true)) {
169
-				return true;
170
-			}
171
-		}
172
-		return false;
173
-	}
174
-
175
-
176
-	/**
177
-	 * Gets all storages for the user, admin, personal, global, etc
178
-	 *
179
-	 * @return StorageConfig[] array of storage configs
180
-	 */
181
-	public function getAllStoragesForUser() {
182
-		if (is_null($this->getUser())) {
183
-			return [];
184
-		}
185
-		$groupIds = $this->groupManager->getUserGroupIds($this->getUser());
186
-		$mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds);
187
-		$configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
188
-		$configs = array_filter($configs, function ($config) {
189
-			return $config instanceof StorageConfig;
190
-		});
191
-
192
-		$keys = array_map(function (StorageConfig $config) {
193
-			return $config->getId();
194
-		}, $configs);
195
-
196
-		$storages = array_combine($keys, $configs);
197
-		return array_filter($storages, [$this, 'validateStorage']);
198
-	}
36
+    use UserTrait;
37
+
38
+    /** @var IGroupManager */
39
+    protected $groupManager;
40
+
41
+    /**
42
+     * @param BackendService $backendService
43
+     * @param DBConfigService $dbConfig
44
+     * @param IUserSession $userSession
45
+     * @param IGroupManager $groupManager
46
+     * @param IUserMountCache $userMountCache
47
+     */
48
+    public function __construct(
49
+        BackendService $backendService,
50
+        DBConfigService $dbConfig,
51
+        IUserSession $userSession,
52
+        IGroupManager $groupManager,
53
+        IUserMountCache $userMountCache
54
+    ) {
55
+        parent::__construct($backendService, $dbConfig, $userMountCache);
56
+        $this->userSession = $userSession;
57
+        $this->groupManager = $groupManager;
58
+    }
59
+
60
+    /**
61
+     * Replace config hash ID with real IDs, for migrating legacy storages
62
+     *
63
+     * @param StorageConfig[] $storages Storages with real IDs
64
+     * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs
65
+     */
66
+    protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) {
67
+        // as a read-only view, storage IDs don't need to be real
68
+        foreach ($storagesWithConfigHash as $storage) {
69
+            $storages[$storage->getId()] = $storage;
70
+        }
71
+    }
72
+
73
+    protected function readDBConfig() {
74
+        $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
75
+        $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
76
+        $groups = $this->groupManager->getUserGroupIds($this->getUser());
77
+        if (is_array($groups) && count($groups) !== 0) {
78
+            $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups);
79
+        } else {
80
+            $groupMounts = [];
81
+        }
82
+        return array_merge($userMounts, $groupMounts, $globalMounts);
83
+    }
84
+
85
+    public function addStorage(StorageConfig $newStorage) {
86
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
87
+    }
88
+
89
+    public function updateStorage(StorageConfig $updatedStorage) {
90
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
91
+    }
92
+
93
+    /**
94
+     * @param integer $id
95
+     */
96
+    public function removeStorage($id) {
97
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
98
+    }
99
+
100
+    /**
101
+     * Get unique storages, in case two are defined with the same mountpoint
102
+     * Higher priority storages take precedence
103
+     *
104
+     * @return StorageConfig[]
105
+     */
106
+    public function getUniqueStorages() {
107
+        $storages = $this->getStorages();
108
+
109
+        $storagesByMountpoint = [];
110
+        foreach ($storages as $storage) {
111
+            $storagesByMountpoint[$storage->getMountPoint()][] = $storage;
112
+        }
113
+
114
+        $result = [];
115
+        foreach ($storagesByMountpoint as $storageList) {
116
+            $storage = array_reduce($storageList, function ($carry, $item) {
117
+                if (isset($carry)) {
118
+                    $carryPriorityType = $this->getPriorityType($carry);
119
+                    $itemPriorityType = $this->getPriorityType($item);
120
+                    if ($carryPriorityType > $itemPriorityType) {
121
+                        return $carry;
122
+                    } elseif ($carryPriorityType === $itemPriorityType) {
123
+                        if ($carry->getPriority() > $item->getPriority()) {
124
+                            return $carry;
125
+                        }
126
+                    }
127
+                }
128
+                return $item;
129
+            });
130
+            $result[$storage->getID()] = $storage;
131
+        }
132
+
133
+        return $result;
134
+    }
135
+
136
+    /**
137
+     * Get a priority 'type', where a bigger number means higher priority
138
+     * user applicable > group applicable > 'all'
139
+     *
140
+     * @param StorageConfig $storage
141
+     * @return int
142
+     */
143
+    protected function getPriorityType(StorageConfig $storage) {
144
+        $applicableUsers = $storage->getApplicableUsers();
145
+        $applicableGroups = $storage->getApplicableGroups();
146
+
147
+        if ($applicableUsers && $applicableUsers[0] !== 'all') {
148
+            return 2;
149
+        }
150
+        if ($applicableGroups) {
151
+            return 1;
152
+        }
153
+        return 0;
154
+    }
155
+
156
+    protected function isApplicable(StorageConfig $config) {
157
+        $applicableUsers = $config->getApplicableUsers();
158
+        $applicableGroups = $config->getApplicableGroups();
159
+
160
+        if (count($applicableUsers) === 0 && count($applicableGroups) === 0) {
161
+            return true;
162
+        }
163
+        if (in_array($this->getUser()->getUID(), $applicableUsers, true)) {
164
+            return true;
165
+        }
166
+        $groupIds = $this->groupManager->getUserGroupIds($this->getUser());
167
+        foreach ($groupIds as $groupId) {
168
+            if (in_array($groupId, $applicableGroups, true)) {
169
+                return true;
170
+            }
171
+        }
172
+        return false;
173
+    }
174
+
175
+
176
+    /**
177
+     * Gets all storages for the user, admin, personal, global, etc
178
+     *
179
+     * @return StorageConfig[] array of storage configs
180
+     */
181
+    public function getAllStoragesForUser() {
182
+        if (is_null($this->getUser())) {
183
+            return [];
184
+        }
185
+        $groupIds = $this->groupManager->getUserGroupIds($this->getUser());
186
+        $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds);
187
+        $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
188
+        $configs = array_filter($configs, function ($config) {
189
+            return $config instanceof StorageConfig;
190
+        });
191
+
192
+        $keys = array_map(function (StorageConfig $config) {
193
+            return $config->getId();
194
+        }, $configs);
195
+
196
+        $storages = array_combine($keys, $configs);
197
+        return array_filter($storages, [$this, 'validateStorage']);
198
+    }
199 199
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/PriorityTrait.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@
 block discarded – undo
29 29
  */
30 30
 trait PriorityTrait {
31 31
 
32
-	/** @var int initial priority */
33
-	protected $priority = BackendService::PRIORITY_DEFAULT;
32
+    /** @var int initial priority */
33
+    protected $priority = BackendService::PRIORITY_DEFAULT;
34 34
 
35
-	/**
36
-	 * @return int
37
-	 */
38
-	public function getPriority() {
39
-		return $this->priority;
40
-	}
35
+    /**
36
+     * @return int
37
+     */
38
+    public function getPriority() {
39
+        return $this->priority;
40
+    }
41 41
 
42
-	/**
43
-	 * @param int $priority
44
-	 * @return self
45
-	 */
46
-	public function setPriority($priority) {
47
-		$this->priority = $priority;
48
-		return $this;
49
-	}
42
+    /**
43
+     * @param int $priority
44
+     * @return self
45
+     */
46
+    public function setPriority($priority) {
47
+        $this->priority = $priority;
48
+        return $this;
49
+    }
50 50
 
51
-	/**
52
-	 * @param PriorityTrait $a
53
-	 * @param PriorityTrait $b
54
-	 * @return int
55
-	 */
56
-	public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) {
57
-		return ($a->getPriority() - $b->getPriority());
58
-	}
51
+    /**
52
+     * @param PriorityTrait $a
53
+     * @param PriorityTrait $b
54
+     * @return int
55
+     */
56
+    public static function priorityCompare(PriorityTrait $a, PriorityTrait $b) {
57
+        return ($a->getPriority() - $b->getPriority());
58
+    }
59 59
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Notify/SMBNotifyHandler.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -29,122 +29,122 @@
 block discarded – undo
29 29
 use OCP\Files\Notify\INotifyHandler;
30 30
 
31 31
 class SMBNotifyHandler implements INotifyHandler {
32
-	/**
33
-	 * @var \Icewind\SMB\INotifyHandler
34
-	 */
35
-	private $shareNotifyHandler;
32
+    /**
33
+     * @var \Icewind\SMB\INotifyHandler
34
+     */
35
+    private $shareNotifyHandler;
36 36
 
37
-	/**
38
-	 * @var string
39
-	 */
40
-	private $root;
37
+    /**
38
+     * @var string
39
+     */
40
+    private $root;
41 41
 
42
-	private $oldRenamePath = null;
42
+    private $oldRenamePath = null;
43 43
 
44
-	/**
45
-	 * SMBNotifyHandler constructor.
46
-	 *
47
-	 * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler
48
-	 * @param string $root
49
-	 */
50
-	public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) {
51
-		$this->shareNotifyHandler = $shareNotifyHandler;
52
-		$this->root = $root;
53
-	}
44
+    /**
45
+     * SMBNotifyHandler constructor.
46
+     *
47
+     * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler
48
+     * @param string $root
49
+     */
50
+    public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) {
51
+        $this->shareNotifyHandler = $shareNotifyHandler;
52
+        $this->root = $root;
53
+    }
54 54
 
55
-	private function relativePath($fullPath) {
56
-		if ($fullPath === $this->root) {
57
-			return '';
58
-		} elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) {
59
-			return substr($fullPath, strlen($this->root));
60
-		} else {
61
-			return null;
62
-		}
63
-	}
55
+    private function relativePath($fullPath) {
56
+        if ($fullPath === $this->root) {
57
+            return '';
58
+        } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) {
59
+            return substr($fullPath, strlen($this->root));
60
+        } else {
61
+            return null;
62
+        }
63
+    }
64 64
 
65
-	public function listen(callable $callback) {
66
-		$oldRenamePath = null;
67
-		$this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) {
68
-			$change = $this->mapChange($shareChange);
69
-			if (!is_null($change)) {
70
-				return $callback($change);
71
-			} else {
72
-				return true;
73
-			}
74
-		});
75
-	}
65
+    public function listen(callable $callback) {
66
+        $oldRenamePath = null;
67
+        $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) {
68
+            $change = $this->mapChange($shareChange);
69
+            if (!is_null($change)) {
70
+                return $callback($change);
71
+            } else {
72
+                return true;
73
+            }
74
+        });
75
+    }
76 76
 
77
-	/**
78
-	 * Get all changes detected since the start of the notify process or the last call to getChanges
79
-	 *
80
-	 * @return IChange[]
81
-	 */
82
-	public function getChanges() {
83
-		$shareChanges = $this->shareNotifyHandler->getChanges();
84
-		$changes = [];
85
-		foreach ($shareChanges as $shareChange) {
86
-			$change = $this->mapChange($shareChange);
87
-			if ($change) {
88
-				$changes[] = $change;
89
-			}
90
-		}
91
-		return $changes;
92
-	}
77
+    /**
78
+     * Get all changes detected since the start of the notify process or the last call to getChanges
79
+     *
80
+     * @return IChange[]
81
+     */
82
+    public function getChanges() {
83
+        $shareChanges = $this->shareNotifyHandler->getChanges();
84
+        $changes = [];
85
+        foreach ($shareChanges as $shareChange) {
86
+            $change = $this->mapChange($shareChange);
87
+            if ($change) {
88
+                $changes[] = $change;
89
+            }
90
+        }
91
+        return $changes;
92
+    }
93 93
 
94
-	/**
95
-	 * Stop listening for changes
96
-	 *
97
-	 * Note that any pending changes will be discarded
98
-	 */
99
-	public function stop() {
100
-		$this->shareNotifyHandler->stop();
101
-	}
94
+    /**
95
+     * Stop listening for changes
96
+     *
97
+     * Note that any pending changes will be discarded
98
+     */
99
+    public function stop() {
100
+        $this->shareNotifyHandler->stop();
101
+    }
102 102
 
103
-	/**
104
-	 * @param \Icewind\SMB\Change $change
105
-	 * @return IChange|null
106
-	 */
107
-	private function mapChange(\Icewind\SMB\Change $change) {
108
-		$path = $this->relativePath($change->getPath());
109
-		if (is_null($path)) {
110
-			return null;
111
-		}
112
-		if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) {
113
-			$this->oldRenamePath = $path;
114
-			return null;
115
-		}
116
-		$type = $this->mapNotifyType($change->getCode());
117
-		if (is_null($type)) {
118
-			return null;
119
-		}
120
-		if ($type === IChange::RENAMED) {
121
-			if (!is_null($this->oldRenamePath)) {
122
-				$result = new RenameChange($type, $this->oldRenamePath, $path);
123
-				$this->oldRenamePath = null;
124
-			} else {
125
-				$result = null;
126
-			}
127
-		} else {
128
-			$result = new Change($type, $path);
129
-		}
130
-		return $result;
131
-	}
103
+    /**
104
+     * @param \Icewind\SMB\Change $change
105
+     * @return IChange|null
106
+     */
107
+    private function mapChange(\Icewind\SMB\Change $change) {
108
+        $path = $this->relativePath($change->getPath());
109
+        if (is_null($path)) {
110
+            return null;
111
+        }
112
+        if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) {
113
+            $this->oldRenamePath = $path;
114
+            return null;
115
+        }
116
+        $type = $this->mapNotifyType($change->getCode());
117
+        if (is_null($type)) {
118
+            return null;
119
+        }
120
+        if ($type === IChange::RENAMED) {
121
+            if (!is_null($this->oldRenamePath)) {
122
+                $result = new RenameChange($type, $this->oldRenamePath, $path);
123
+                $this->oldRenamePath = null;
124
+            } else {
125
+                $result = null;
126
+            }
127
+        } else {
128
+            $result = new Change($type, $path);
129
+        }
130
+        return $result;
131
+    }
132 132
 
133
-	private function mapNotifyType($smbType) {
134
-		switch ($smbType) {
135
-			case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED:
136
-				return IChange::ADDED;
137
-			case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED:
138
-				return IChange::REMOVED;
139
-			case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED:
140
-			case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM:
141
-			case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM:
142
-			case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM:
143
-				return IChange::MODIFIED;
144
-			case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW:
145
-				return IChange::RENAMED;
146
-			default:
147
-				return null;
148
-		}
149
-	}
133
+    private function mapNotifyType($smbType) {
134
+        switch ($smbType) {
135
+            case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED:
136
+                return IChange::ADDED;
137
+            case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED:
138
+                return IChange::REMOVED;
139
+            case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED:
140
+            case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM:
141
+            case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM:
142
+            case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM:
143
+                return IChange::MODIFIED;
144
+            case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW:
145
+                return IChange::RENAMED;
146
+            default:
147
+                return null;
148
+        }
149
+    }
150 150
 }
Please login to merge, or discard this patch.