Fix directories with nested files not showing

Fix cwd showing "/sdcard/sdcard" directories
This commit is contained in:
Mahdi Dibaiee
2015-09-15 17:57:43 +04:30
parent 6e52ca6246
commit d52fe9f9bc
6 changed files with 14 additions and 16 deletions

View File

@ -31995,6 +31995,7 @@ exports['default'] = function (state, action) {
};
function changeTo(dir) {
dir = (0, _utils.normalize)(dir);
(0, _apiFiles.children)(dir, true).then(function (files) {
_store2['default'].dispatch((0, _actionsFilesView.listFiles)(files));
}, _utils.reportError);

View File

@ -41,24 +41,22 @@ function shimDirectory(directory) {
return;
}
var parts = this.result.name.replace('/sdcard/', '').split('/');
var normalized = this.result.name.replace('/sdcard/', '');
var parts = normalized.split('/');
// immediate children files
if (parts.slice(0, -1).join('/') === current) {
console.log('constructing file');
var file = new File([this.result], parts[parts.length - 1], {
type: this.result.type
});
console.log('defining path');
Object.defineProperty(file, 'path', {
value: parts.slice(0, -1).join('/') + '/'
});
children.push(file);
// Directories
} else if (parts.slice(0, -2).join('/') === current) {
var path = parts.slice(0, -2).join('/') + '/';
var name = parts[parts.length - 2];
} else if (normalized.indexOf(current) === 0) {
var name = normalized.slice(current.length).replace(/^\//, '').split('/')[0];
var exists = children.some(function(child) {
return child.name === name
@ -67,7 +65,7 @@ function shimDirectory(directory) {
if (!exists) {
var dir = Object.assign({}, directory);
dir.name = name;
dir.path = path;
dir.path = current + '/';
children.push(dir);
}
}