From 4829a2d421902e0edede30a71c96a86c576a17b1 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 23 Feb 2016 15:16:13 +0100 Subject: [PATCH] Disable sharing by default for external storage mounts This is for newly created mount points. Migrated mount points will have sharing enabled as before. --- apps/files_external/js/settings.js | 4 ++-- apps/files_external/lib/storageconfig.php | 1 + apps/files_external/migration/storagemigrator.php | 6 ++++++ apps/files_external/tests/js/settingsSpec.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 26df203091e..96b56d221c5 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -23,7 +23,7 @@ var MOUNT_OPTIONS_DROPDOWN_TEMPLATE = ' ' + ' ' + '
' + - ' ' + + ' ' + ' ' + '
' + '
' + @@ -888,7 +888,7 @@ MountConfigListView.prototype = _.extend({ $tr.find('input.mountOptions').val(JSON.stringify({ 'encrypt': true, 'previews': true, - 'enable_sharing': true, + 'enable_sharing': false, 'filesystem_check_changes': 1 })); } diff --git a/apps/files_external/lib/storageconfig.php b/apps/files_external/lib/storageconfig.php index 6f44b25a2e6..42c515f4671 100644 --- a/apps/files_external/lib/storageconfig.php +++ b/apps/files_external/lib/storageconfig.php @@ -126,6 +126,7 @@ class StorageConfig implements \JsonSerializable { */ public function __construct($id = null) { $this->id = $id; + $this->mountOptions['enable_sharing'] = false; } /** diff --git a/apps/files_external/migration/storagemigrator.php b/apps/files_external/migration/storagemigrator.php index ba81810a4fd..832807feb93 100644 --- a/apps/files_external/migration/storagemigrator.php +++ b/apps/files_external/migration/storagemigrator.php @@ -100,6 +100,12 @@ class StorageMigrator { $this->connection->beginTransaction(); try { foreach ($existingStorage as $storage) { + $mountOptions = $storage->getMountOptions(); + if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { + // existing mounts must have sharing enabled by default to avoid surprises + $mountOptions['enable_sharing'] = true; + $storage->setMountOptions($mountOptions); + } $storageService->addStorage($storage); } $this->connection->commit(); diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js index 6f5bb2a8e3e..2a7afd6c2fa 100644 --- a/apps/files_external/tests/js/settingsSpec.js +++ b/apps/files_external/tests/js/settingsSpec.js @@ -363,7 +363,7 @@ describe('OCA.External.Settings tests', function() { expect(JSON.parse($tr.find('input.mountOptions').val())).toEqual({ encrypt: true, previews: true, - enable_sharing: true, + enable_sharing: false, filesystem_check_changes: 0 }); }); -- 2.39.5