[Pkg-owncloud-commits] [owncloud] 76/172: Extract mount point merging logic into separate function
David Prévot
taffit at moszumanska.debian.org
Sun May 18 20:09:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 08a8a409d64051f3d20e6ea8ba1507f144a1b30d
Author: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date: Tue May 13 00:14:30 2014 +0100
Extract mount point merging logic into separate function
---
apps/files_external/lib/config.php | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 15fbda9..9906b76 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -400,19 +400,11 @@ class OC_Mount_Config {
'options' => self::encryptPasswords($classOptions))
)
);
+
$mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
- // Merge the new mount point into the current mount points
- if (isset($mountPoints[$mountType])) {
- if (isset($mountPoints[$mountType][$applicable])) {
- $mountPoints[$mountType][$applicable]
- = array_merge($mountPoints[$mountType][$applicable], $mount[$applicable]);
- } else {
- $mountPoints[$mountType] = array_merge($mountPoints[$mountType], $mount);
- }
- } else {
- $mountPoints[$mountType] = $mount;
- }
+ $mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType);
self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
+
return self::getBackendStatus($class, $classOptions, $isPersonal);
}
@@ -690,6 +682,28 @@ class OC_Mount_Config {
}
/**
+ * Merges mount points
+ * @param array $data Existing mount points
+ * @param array $mountPoint New mount point
+ * @param string $mountType
+ * @return array
+ */
+ private static function mergeMountPoints($data, $mountPoint, $mountType) {
+ $applicable = key($mountPoint);
+ if (isset($data[$mountType])) {
+ if (isset($data[$mountType][$applicable])) {
+ $data[$mountType][$applicable]
+ = array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
+ } else {
+ $data[$mountType] = array_merge($data[$mountType], $mountPoint);
+ }
+ } else {
+ $data[$mountType] = $mountPoint;
+ }
+ return $data;
+ }
+
+ /**
* Returns the encryption cipher
*/
private static function getCipher() {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list