Add encoding wrapper as opt-in mount option
The encoding wrapper is now only applied when the mount option is set, disabled by default.
This commit is contained in:
parent
63bbbf29f4
commit
db4c7fe743
|
@ -33,8 +33,12 @@ var MOUNT_OPTIONS_DROPDOWN_TEMPLATE =
|
|||
' <option value="1" selected="selected">{{t "files_external" "Once every direct access"}}</option>' +
|
||||
' </select>' +
|
||||
' </div>' +
|
||||
' <div class="optionRow">' +
|
||||
' <input id="mountOptionsEncoding" name="encoding_compatibility" type="checkbox" value="true"/>' +
|
||||
' <label for="mountOptionsEncoding">{{t "files_external" "Enable encoding compatibility (decreases performance)"}}</label>' +
|
||||
' </div>' +
|
||||
'</div>';
|
||||
|
||||
|
||||
/**
|
||||
* Returns the selection of applicable users in the given configuration row
|
||||
*
|
||||
|
@ -476,9 +480,9 @@ MountOptionsDropdown.prototype = {
|
|||
*
|
||||
* @param {Object} $container container
|
||||
* @param {Object} mountOptions mount options
|
||||
* @param {Array} enabledOptions enabled mount options
|
||||
* @param {Array} visibleOptions enabled mount options
|
||||
*/
|
||||
show: function($container, mountOptions, enabledOptions) {
|
||||
show: function($container, mountOptions, visibleOptions) {
|
||||
if (MountOptionsDropdown._last) {
|
||||
MountOptionsDropdown._last.hide();
|
||||
}
|
||||
|
@ -492,7 +496,7 @@ MountOptionsDropdown.prototype = {
|
|||
var $el = $(template());
|
||||
this.$el = $el;
|
||||
|
||||
this.setOptions(mountOptions, enabledOptions);
|
||||
this.setOptions(mountOptions, visibleOptions);
|
||||
|
||||
this.$el.appendTo($container);
|
||||
MountOptionsDropdown._last = this;
|
||||
|
@ -538,9 +542,9 @@ MountOptionsDropdown.prototype = {
|
|||
* Sets the mount options to the dropdown controls
|
||||
*
|
||||
* @param {Object} options mount options
|
||||
* @param {Array} enabledOptions enabled mount options
|
||||
* @param {Array} visibleOptions enabled mount options
|
||||
*/
|
||||
setOptions: function(options, enabledOptions) {
|
||||
setOptions: function(options, visibleOptions) {
|
||||
var $el = this.$el;
|
||||
_.each(options, function(value, key) {
|
||||
var $optionEl = $el.find('input, select').filterAttr('name', key);
|
||||
|
@ -556,7 +560,7 @@ MountOptionsDropdown.prototype = {
|
|||
$el.find('.optionRow').each(function(i, row){
|
||||
var $row = $(row);
|
||||
var optionId = $row.find('input, select').attr('name');
|
||||
if (enabledOptions.indexOf(optionId) === -1) {
|
||||
if (visibleOptions.indexOf(optionId) === -1) {
|
||||
$row.hide();
|
||||
} else {
|
||||
$row.show();
|
||||
|
@ -883,7 +887,8 @@ MountConfigListView.prototype = _.extend({
|
|||
'encrypt': true,
|
||||
'previews': true,
|
||||
'enable_sharing': false,
|
||||
'filesystem_check_changes': 1
|
||||
'filesystem_check_changes': 1,
|
||||
'encoding_compatibility': false
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -1253,11 +1258,16 @@ MountConfigListView.prototype = _.extend({
|
|||
var storage = this.getStorageConfig($tr);
|
||||
var $toggle = $tr.find('.mountOptionsToggle');
|
||||
var dropDown = new MountOptionsDropdown();
|
||||
var enabledOptions = ['previews', 'filesystem_check_changes', 'enable_sharing'];
|
||||
var visibleOptions = [
|
||||
'previews',
|
||||
'filesystem_check_changes',
|
||||
'enable_sharing',
|
||||
'encoding_compatibility'
|
||||
];
|
||||
if (this._encryptionEnabled) {
|
||||
enabledOptions.push('encrypt');
|
||||
visibleOptions.push('encrypt');
|
||||
}
|
||||
dropDown.show($toggle, storage.mountOptions || [], enabledOptions);
|
||||
dropDown.show($toggle, storage.mountOptions || [], visibleOptions);
|
||||
$('body').on('mouseup.mountOptionsDropdown', function(event) {
|
||||
var $target = $(event.target);
|
||||
if ($toggle.has($target).length) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
$l->t("Check for changes");
|
||||
$l->t("Never");
|
||||
$l->t("Once every direct access");
|
||||
$l->t("Enable encoding compatibility (decreases performance)");
|
||||
|
||||
script('files_external', 'settings');
|
||||
style('files_external', 'settings');
|
||||
|
|
|
@ -370,7 +370,8 @@ describe('OCA.External.Settings tests', function() {
|
|||
encrypt: true,
|
||||
previews: true,
|
||||
enable_sharing: false,
|
||||
filesystem_check_changes: 0
|
||||
filesystem_check_changes: 0,
|
||||
encoding_compatibility: false
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -172,10 +172,8 @@ class OC_Util {
|
|||
return $storage;
|
||||
});
|
||||
|
||||
// install storage availability wrapper, before most other wrappers
|
||||
\OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, $storage) {
|
||||
// TODO: only do this opt-in if the mount option is specified
|
||||
if (!$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) {
|
||||
\OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) {
|
||||
if ($mount->getOption('encoding_compatibility', true) && !$storage->instanceOfStorage('\OC\Files\Storage\Shared') && !$storage->isLocal()) {
|
||||
return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]);
|
||||
}
|
||||
return $storage;
|
||||
|
|
Loading…
Reference in New Issue