]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added filesystem hooks for mount/unmount ext storage
authorVincent Petry <pvince81@owncloud.com>
Thu, 25 Sep 2014 18:17:52 +0000 (20:17 +0200)
committerVincent Petry <pvince81@owncloud.com>
Wed, 8 Oct 2014 12:22:17 +0000 (14:22 +0200)
apps/files_external/lib/config.php

index 952463b8015c985fc7c308bc13d80e18e25b8f25..2a32d239b4cba54609c186ebfd1541eb10e97912 100755 (executable)
@@ -495,6 +495,10 @@ class OC_Mount_Config {
                }
 
                $mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
+               // who else loves multi-dimensional array ?
+               $isNew = !isset($mountPoints[$mountType]) ||
+                       !isset($mountPoints[$mountType][$applicable]) ||
+                       !isset($mountPoints[$mountType][$applicable][$mountPoint]);
                $mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType);
 
                // Set default priority if none set
@@ -510,7 +514,19 @@ class OC_Mount_Config {
 
                self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
 
-               return self::getBackendStatus($class, $classOptions, $isPersonal);
+               $result = self::getBackendStatus($class, $classOptions, $isPersonal);
+               if ($result && $isNew) {
+                       \OC_Hook::emit(
+                               \OC\Files\Filesystem::CLASSNAME,
+                               'add_mount_point',
+                               array(
+                                       'path' => $mountPoint,
+                                       'type' => $mountType,
+                                       'applicable' => $applicable
+                               )
+                       );
+               }
+               return $result;
        }
 
        /**
@@ -543,6 +559,15 @@ class OC_Mount_Config {
                        }
                }
                self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints);
+               \OC_Hook::emit(
+                       \OC\Files\Filesystem::CLASSNAME,
+                       'remove_mount_point',
+                       array(
+                               'path' => $mountPoint,
+                               'type' => $mountType,
+                               'applicable' => $applicable
+                       )
+               );
                return true;
        }