Commit bc11663d authored by yann300's avatar yann300

fix file normalization

parent b3782838
...@@ -17,14 +17,17 @@ function FilesTree (name, storage) { ...@@ -17,14 +17,17 @@ function FilesTree (name, storage) {
function updateRefs (path, type) { function updateRefs (path, type) {
var split = path.split('/') // this should be unprefixed path var split = path.split('/') // this should be unprefixed path
var crawlpath = self.tree var crawlpath = self.tree
var intermediatePath = ''
split.forEach((pathPart, index) => { split.forEach((pathPart, index) => {
if (!crawlpath[pathPart]) crawlpath[pathPart] = {} intermediatePath += pathPart
if (!crawlpath[pathPart]) crawlpath[intermediatePath] = {}
if (index < split.length - 1) { if (index < split.length - 1) {
crawlpath = crawlpath[pathPart] crawlpath = crawlpath[intermediatePath]
intermediatePath += '/'
} else if (type === 'add') { } else if (type === 'add') {
crawlpath[pathPart] = path crawlpath[intermediatePath] = path
} else if (type === 'remove' && crawlpath[pathPart]) { } else if (type === 'remove' && crawlpath[intermediatePath]) {
delete crawlpath[pathPart] delete crawlpath[intermediatePath]
} }
}) })
storage.set(self.structFile, JSON.stringify(self.tree)) storage.set(self.structFile, JSON.stringify(self.tree))
......
...@@ -173,9 +173,10 @@ function fileExplorer (appAPI, files) { ...@@ -173,9 +173,10 @@ function fileExplorer (appAPI, files) {
}) })
function normalize (path, filesList) { function normalize (path, filesList) {
var prefix = path.split('/')[0]
var newList = {} var newList = {}
Object.keys(filesList).forEach(key => { Object.keys(filesList).forEach(key => {
newList[path + '/' + key] = filesList[key].isDirectory ? {} : { '/content': true } newList[prefix + '/' + key] = filesList[key].isDirectory ? {} : { '/content': true }
}) })
return newList return newList
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment