From e78ed7e680463e656fae22d1c6ed765a7c63b5ec Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 12 Sep 2018 09:10:44 +0200 Subject: [PATCH] add callback to provider set --- src/app/files/browser-files-tree.js | 4 +++- src/app/files/browser-files.js | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/files/browser-files-tree.js b/src/app/files/browser-files-tree.js index b9bde21c2d..16ce5a60c2 100644 --- a/src/app/files/browser-files-tree.js +++ b/src/app/files/browser-files-tree.js @@ -53,11 +53,12 @@ function FilesTree (name, storage) { return content } - this.set = function (path, content) { + this.set = function (path, content, cb) { var unprefixedpath = this.removePrefix(path) updateRefs(unprefixedpath, 'add') var exists = storage.exists(unprefixedpath) if (!storage.set(unprefixedpath, content)) { + if (cb) cb('error updating ' + path) return false } if (!exists) { @@ -65,6 +66,7 @@ function FilesTree (name, storage) { } else { event.trigger('fileChanged', [this.type + '/' + unprefixedpath]) } + if (cb) cb() return true } diff --git a/src/app/files/browser-files.js b/src/app/files/browser-files.js index e0a25e6db8..8179622f02 100644 --- a/src/app/files/browser-files.js +++ b/src/app/files/browser-files.js @@ -38,16 +38,18 @@ function Files (storage) { return content } - this.set = function (path, content) { + this.set = function (path, content, cb) { var unprefixedpath = this.removePrefix(path) // NOTE: ignore the config file if (path === '.remix.config') { + if (cb) cb('change not allowed') return false } if (!this.isReadOnly(unprefixedpath)) { var exists = storage.exists(unprefixedpath) if (!storage.set(unprefixedpath, content)) { + if (cb) cb('error updating ' + path) return false } if (!exists) { @@ -55,9 +57,10 @@ function Files (storage) { } else { event.trigger('fileChanged', [this.type + '/' + unprefixedpath]) } + if (cb) cb() return true } - + if (cb) cb('is read only') return false }