fix folder removal

pull/1/head
yann300 8 years ago
parent 5fee645c31
commit 9bfd3e6520
  1. 5
      src/app/file-explorer.js

@ -183,7 +183,7 @@ function fileExplorer (appAPI, files) {
if (isFolder) path += '/' if (isFolder) path += '/'
if (confirm(`Do you really want to delete "${path}" ?`)) { if (confirm(`Do you really want to delete "${path}" ?`)) {
li.parentElement.removeChild(li) li.parentElement.removeChild(li)
removeSubtree(files, path) removeSubtree(files, path, isFolder)
} }
} }
@ -343,7 +343,7 @@ function getLabelFrom (li) {
return li.children[0].children[1].children[0] return li.children[0].children[1].children[0]
} }
function removeSubtree (files, path) { function removeSubtree (files, path, isFolder) {
var parts = path.split('/') var parts = path.split('/')
var isFile = parts[parts.length - 1].length var isFile = parts[parts.length - 1].length
var removePaths = isFile ? [path] : Object.keys(files.list()).filter(keep) var removePaths = isFile ? [path] : Object.keys(files.list()).filter(keep)
@ -357,6 +357,7 @@ function removeSubtree (files, path) {
}) })
files.remove(path) files.remove(path)
}) })
if (isFolder) files.remove(path)
} }
function expandPathTo (li) { function expandPathTo (li) {

Loading…
Cancel
Save