From 538d37f9aac463bce4ec517c9782abaefa4e8ec9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Dec 2017 16:02:32 +0100 Subject: [PATCH] fix save readonly explorer file --- src/app/files/basicReadOnlyExplorer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/files/basicReadOnlyExplorer.js b/src/app/files/basicReadOnlyExplorer.js index f6f7d09bb6..fa8f49d81f 100644 --- a/src/app/files/basicReadOnlyExplorer.js +++ b/src/app/files/basicReadOnlyExplorer.js @@ -32,15 +32,18 @@ class BasicReadOnlyExplorer { } set (path, content, cb) { + this.addReadOnly(path, content) + if (cb) cb() return true } addReadOnly (path, content) { + var unprefixedPath = this.removePrefix(path) try { // lazy try to format JSON content = JSON.stringify(JSON.parse(content), null, '\t') } catch (e) {} - this.files[this.type + '/' + path] = content - this.event.trigger('fileAdded', [this.type + '/' + path, true]) + this.files[this.type + '/' + unprefixedPath] = content + this.event.trigger('fileAdded', [this.type + '/' + unprefixedPath, true]) return true } @@ -101,6 +104,10 @@ class BasicReadOnlyExplorer { }) return tree } + + removePrefix (path) { + return path.indexOf(this.type + '/') === 0 ? path.replace(this.type + '/', '') : path + } } module.exports = BasicReadOnlyExplorer