]> source.dussan.org Git - nextcloud-server.git/commitdiff
When changing the mountpoint of an external storage, ensure the old one is removed
authorRobin Appelman <icewind@owncloud.com>
Mon, 7 Jul 2014 13:40:01 +0000 (15:40 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 7 Jul 2014 13:40:01 +0000 (15:40 +0200)
apps/files_external/ajax/addMountPoint.php
apps/files_external/js/settings.js
apps/files_external/templates/settings.php

index 9100d47db3a5494c9f54459511a797e474e91849..4903120c2a84d299b237ffd220f0c17a12c699c9 100644 (file)
@@ -10,10 +10,17 @@ if ($_POST['isPersonal'] == 'true') {
        OCP\JSON::checkAdminUser();
        $isPersonal = false;
 }
-$status = OC_Mount_Config::addMountPoint($_POST['mountPoint'],
-                                                          $_POST['class'],
-                                                          $_POST['classOptions'],
-                                                          $_POST['mountType'],
-                                                          $_POST['applicable'],
-                                                          $isPersonal);
+
+$mountPoint = $_POST['mountPoint'];
+$oldMountPoint = $_POST['oldMountPoint'];
+$class = $_POST['class'];
+$options = $_POST['classOptions'];
+$type = $_POST['mountType'];
+$applicable = $_POST['applicable'];
+
+if ($oldMountPoint and $oldMountPoint !== $mountPoint) {
+       OC_Mount_Config::removeMountPoint($oldMountPoint, $type, $applicable, $isPersonal);
+}
+
+$status = OC_Mount_Config::addMountPoint($mountPoint, $class, $options, $type, $applicable, $isPersonal);
 OCP\JSON::success(array('data' => array('message' => $status)));
index 348fecf0648ea3d09f588a2037ee70102d0bcf07..be6860bab63f930d87d4e89ed43dce50c86c4ef4 100644 (file)
@@ -14,6 +14,7 @@ function updateStatus(statusEl, result){
 OC.MountConfig={
        saveStorage:function(tr, callback) {
                var mountPoint = $(tr).find('.mountPoint input').val();
+               var oldMountPoint = $(tr).find('.mountPoint input').data('mountpoint');
                if (mountPoint == '') {
                        return false;
                }
@@ -80,9 +81,11 @@ OC.MountConfig={
                                                        classOptions: classOptions,
                                                        mountType: mountType,
                                                        applicable: applicable,
-                                                       isPersonal: isPersonal
+                                                       isPersonal: isPersonal,
+                                                       oldMountPoint: oldMountPoint
                                                },
                                                success: function(result) {
+                                                       $(tr).find('.mountPoint input').data('mountpoint', mountPoint);
                                                        status = updateStatus(statusSpan, result);
                                                        if (callback) {
                                                                callback(status);
@@ -139,9 +142,11 @@ OC.MountConfig={
                                                classOptions: classOptions,
                                                mountType: mountType,
                                                applicable: applicable,
-                                               isPersonal: isPersonal
+                                               isPersonal: isPersonal,
+                                               oldMountPoint: oldMountPoint
                                        },
                                        success: function(result) {
+                                               $(tr).find('.mountPoint input').data('mountpoint', mountPoint);
                                                status = updateStatus(statusSpan, result);
                                                if (callback) {
                                                        callback(status);
index 98fcf4a0ed499201089c333142396eb42eaa024b..dcf3938b89445bc116cd13b24c1a6315da505298 100644 (file)
@@ -24,6 +24,7 @@
                                </td>
                                <td class="mountPoint"><input type="text" name="mountPoint"
                                                                                          value="<?php p(isset($mount['mountpoint']) ? $mount['mountpoint'] : ''); ?>"
+                                                                                         data-mountpoint="<?php p(isset($mount['mountpoint']) ? $mount['mountpoint'] : ''); ?>"
                                                                                          placeholder="<?php p($l->t('Folder name')); ?>" /></td>
                                <?php if (!isset($mount['mountpoint'])): ?>
                                        <td class="backend">