Merge pull request #9495 from owncloud/remove-moved-mount

When changing the mountpoint of an external storage, ensure the old one ...
This commit is contained in:
Vincent Petry 2014-07-07 23:23:04 +02:00
commit 5506f9dc81
3 changed files with 21 additions and 8 deletions

View File

@ -10,10 +10,17 @@ if ($_POST['isPersonal'] == 'true') {
OCP\JSON::checkAdminUser(); OCP\JSON::checkAdminUser();
$isPersonal = false; $isPersonal = false;
} }
$status = OC_Mount_Config::addMountPoint($_POST['mountPoint'],
$_POST['class'], $mountPoint = $_POST['mountPoint'];
$_POST['classOptions'], $oldMountPoint = $_POST['oldMountPoint'];
$_POST['mountType'], $class = $_POST['class'];
$_POST['applicable'], $options = $_POST['classOptions'];
$isPersonal); $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))); OCP\JSON::success(array('data' => array('message' => $status)));

View File

@ -14,6 +14,7 @@ function updateStatus(statusEl, result){
OC.MountConfig={ OC.MountConfig={
saveStorage:function(tr, callback) { saveStorage:function(tr, callback) {
var mountPoint = $(tr).find('.mountPoint input').val(); var mountPoint = $(tr).find('.mountPoint input').val();
var oldMountPoint = $(tr).find('.mountPoint input').data('mountpoint');
if (mountPoint == '') { if (mountPoint == '') {
return false; return false;
} }
@ -80,9 +81,11 @@ OC.MountConfig={
classOptions: classOptions, classOptions: classOptions,
mountType: mountType, mountType: mountType,
applicable: applicable, applicable: applicable,
isPersonal: isPersonal isPersonal: isPersonal,
oldMountPoint: oldMountPoint
}, },
success: function(result) { success: function(result) {
$(tr).find('.mountPoint input').data('mountpoint', mountPoint);
status = updateStatus(statusSpan, result); status = updateStatus(statusSpan, result);
if (callback) { if (callback) {
callback(status); callback(status);
@ -139,9 +142,11 @@ OC.MountConfig={
classOptions: classOptions, classOptions: classOptions,
mountType: mountType, mountType: mountType,
applicable: applicable, applicable: applicable,
isPersonal: isPersonal isPersonal: isPersonal,
oldMountPoint: oldMountPoint
}, },
success: function(result) { success: function(result) {
$(tr).find('.mountPoint input').data('mountpoint', mountPoint);
status = updateStatus(statusSpan, result); status = updateStatus(statusSpan, result);
if (callback) { if (callback) {
callback(status); callback(status);

View File

@ -24,6 +24,7 @@
</td> </td>
<td class="mountPoint"><input type="text" name="mountPoint" <td class="mountPoint"><input type="text" name="mountPoint"
value="<?php p(isset($mount['mountpoint']) ? $mount['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> placeholder="<?php p($l->t('Folder name')); ?>" /></td>
<?php if (!isset($mount['mountpoint'])): ?> <?php if (!isset($mount['mountpoint'])): ?>
<td class="backend"> <td class="backend">