Commit 538d37f9 authored by yann300's avatar yann300

fix save readonly explorer file

parent f46b82d9
...@@ -32,15 +32,18 @@ class BasicReadOnlyExplorer { ...@@ -32,15 +32,18 @@ class BasicReadOnlyExplorer {
} }
set (path, content, cb) { set (path, content, cb) {
this.addReadOnly(path, content)
if (cb) cb()
return true return true
} }
addReadOnly (path, content) { addReadOnly (path, content) {
var unprefixedPath = this.removePrefix(path)
try { // lazy try to format JSON try { // lazy try to format JSON
content = JSON.stringify(JSON.parse(content), null, '\t') content = JSON.stringify(JSON.parse(content), null, '\t')
} catch (e) {} } catch (e) {}
this.files[this.type + '/' + path] = content this.files[this.type + '/' + unprefixedPath] = content
this.event.trigger('fileAdded', [this.type + '/' + path, true]) this.event.trigger('fileAdded', [this.type + '/' + unprefixedPath, true])
return true return true
} }
...@@ -101,6 +104,10 @@ class BasicReadOnlyExplorer { ...@@ -101,6 +104,10 @@ class BasicReadOnlyExplorer {
}) })
return tree return tree
} }
removePrefix (path) {
return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path
}
} }
module.exports = BasicReadOnlyExplorer module.exports = BasicReadOnlyExplorer
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