diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
index ffe1e972071..983348397d1 100644
--- a/apps/files_external/js/settings.js
+++ b/apps/files_external/js/settings.js
@@ -48,6 +48,12 @@ var MOUNT_OPTIONS_DROPDOWN_TEMPLATE =
' '+
' '+
' '+
+ '
' +
+ ' ' +
+ ' ' +
' '+
'';
@@ -916,7 +922,8 @@ MountConfigListView.prototype = _.extend({
'previews': true,
'enable_sharing': false,
'filesystem_check_changes': 1,
- 'encoding_compatibility': false
+ 'encoding_compatibility': false,
+ 'readonly': false,
}));
}
@@ -1303,7 +1310,8 @@ MountConfigListView.prototype = _.extend({
'previews',
'filesystem_check_changes',
'enable_sharing',
- 'encoding_compatibility'
+ 'encoding_compatibility',
+ 'readonly'
];
if (this._encryptionEnabled) {
visibleOptions.push('encrypt');
diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php
index efb2669e281..89bdcf5e5d6 100644
--- a/apps/files_external/lib/Command/ListCommand.php
+++ b/apps/files_external/lib/Command/ListCommand.php
@@ -192,7 +192,8 @@ class ListCommand extends Base {
'previews' => true,
'filesystem_check_changes' => 1,
'enable_sharing' => false,
- 'encoding_compatibility' => false
+ 'encoding_compatibility' => false,
+ 'readonly' => false,
];
$rows = array_map(function (StorageConfig $config) use ($userId, $defaultMountOptions, $full) {
$storageConfig = $config->getBackendOptions();
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
index 895be719ab4..236faf37d6d 100644
--- a/apps/files_external/templates/settings.php
+++ b/apps/files_external/templates/settings.php
@@ -12,6 +12,7 @@
$l->t("Check for changes");
$l->t("Never");
$l->t("Once every direct access");
+ $l->t('Read only');
script('files_external', 'settings');
style('files_external', 'settings');
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index d3599d14e7a..356d336f687 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -259,6 +259,23 @@ class OC_Util {
return $storage;
});
+ \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, \OCP\Files\Storage\IStorage $storage, \OCP\Files\Mount\IMountPoint $mount) {
+ /*
+ * Do not allow any operations that modify the storage
+ */
+ if ($mount->getOption('readonly', false)) {
+ return new \OC\Files\Storage\Wrapper\PermissionsMask([
+ 'storage' => $storage,
+ 'mask' => \OCP\Constants::PERMISSION_ALL & ~(
+ \OCP\Constants::PERMISSION_UPDATE |
+ \OCP\Constants::PERMISSION_CREATE |
+ \OCP\Constants::PERMISSION_DELETE
+ ),
+ ]);
+ }
+ return $storage;
+ });
+
OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user));
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true);