From e335b3f55a092d29cc6b5834de1f531cb7cd99ed Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 26 Sep 2019 17:48:09 +0200 Subject: [PATCH] make sure file from gist handler are not duplicated --- src/app/files/fileManager.js | 11 +++++++++-- src/lib/gist-handler.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 88ca3ff8d5..e1b9a57381 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -342,11 +342,18 @@ class FileManager extends Plugin { } } - setBatchFiles (filesSet, fileProvider, callback) { + setBatchFiles (filesSet, fileProvider, override, callback) { const self = this if (!fileProvider) fileProvider = 'browser' + if (override === undefined) override = false async.each(Object.keys(filesSet), (file, callback) => { + if (override) { + self._deps.filesProviders[fileProvider].set(file, filesSet[file].content) + self.syncEditor(fileProvider + file) + return callback() + } + helper.createNonClashingName(file, self._deps.filesProviders[fileProvider], (error, name) => { if (error) { @@ -355,11 +362,11 @@ class FileManager extends Plugin { modalDialogCustom.alert('Special characters are not allowed') } else { self._deps.filesProviders[fileProvider].set(name, filesSet[file].content) + self.syncEditor(fileProvider + name) } callback() }) }, (error) => { - if (!error) self.switchFile() if (callback) callback(error) }) } diff --git a/src/lib/gist-handler.js b/src/lib/gist-handler.js index 30b3e8bc08..43477b4309 100644 --- a/src/lib/gist-handler.js +++ b/src/lib/gist-handler.js @@ -57,7 +57,7 @@ function GistHandler (_window) { Object.keys(data.files).forEach((element) => { obj['/gists/' + gistId + '/' + element] = data.files[element] }) - fileManager.setBatchFiles(obj, 'browser', (errorLoadingFile) => { + fileManager.setBatchFiles(obj, 'browser', true, (errorLoadingFile) => { if (!errorLoadingFile) { gistProvider.id = gistId gistProvider.origGistFiles = data.files