Skip to content

Commit

Permalink
Merge pull request #24349 from owncloud/nfd-storagewrapper
Browse files Browse the repository at this point in the history
Add wrapper for NFD encoding workaround
  • Loading branch information
Vincent Petry committed May 23, 2016
2 parents 862d8f4 + bac8e13 commit bd87f67
Show file tree
Hide file tree
Showing 7 changed files with 771 additions and 15 deletions.
36 changes: 24 additions & 12 deletions apps/files_external/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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">{{mountOptionsEncodingLabel}}</label>' +
' </div>' +
'</div>';

/**
* Returns the selection of applicable users in the given configuration row
*
Expand Down Expand Up @@ -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();
}
Expand All @@ -489,10 +493,12 @@ MountOptionsDropdown.prototype = {
MountOptionsDropdown._template = template;
}

var $el = $(template());
var $el = $(template({
mountOptionsEncodingLabel: t('files_external', 'Compatibility with Mac NFD encoding (slow)')
}));
this.$el = $el;

this.setOptions(mountOptions, enabledOptions);
this.setOptions(mountOptions, visibleOptions);

this.$el.appendTo($container);
MountOptionsDropdown._last = this;
Expand Down Expand Up @@ -538,9 +544,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);
Expand All @@ -556,7 +562,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();
Expand Down Expand Up @@ -883,7 +889,8 @@ MountConfigListView.prototype = _.extend({
'encrypt': true,
'previews': true,
'enable_sharing': false,
'filesystem_check_changes': 1
'filesystem_check_changes': 1,
'encoding_compatibility': false
}));
}

Expand Down Expand Up @@ -1253,11 +1260,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) {
Expand Down
3 changes: 2 additions & 1 deletion apps/files_external/tests/js/settingsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function doDelete($path, $method) {
return false;
}

$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path, true, false, true);
$result = true;
$view = Filesystem::getView();
if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ protected function getNewChildren($folder) {
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
if (!Filesystem::isIgnoredDir($file)) {
$children[] = $file;
$children[] = trim(\OC\Files\Filesystem::normalizePath($file), '/');
}
}
}
Expand Down
Loading

0 comments on commit bd87f67

Please sign in to comment.