Merge pull request #2375 from ethereum/fix_gist_hanlder_files_duplication

Make sure file from gist handler are not duplicated
pull/1/head
yann300 5 years ago committed by GitHub
commit 6ec50ea83a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/app/files/fileManager.js
  2. 2
      src/lib/gist-handler.js

@ -342,11 +342,18 @@ class FileManager extends Plugin {
} }
} }
setBatchFiles (filesSet, fileProvider, callback) { setBatchFiles (filesSet, fileProvider, override, callback) {
const self = this const self = this
if (!fileProvider) fileProvider = 'browser' if (!fileProvider) fileProvider = 'browser'
if (override === undefined) override = false
async.each(Object.keys(filesSet), (file, callback) => { 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], helper.createNonClashingName(file, self._deps.filesProviders[fileProvider],
(error, name) => { (error, name) => {
if (error) { if (error) {
@ -355,11 +362,11 @@ class FileManager extends Plugin {
modalDialogCustom.alert('Special characters are not allowed') modalDialogCustom.alert('Special characters are not allowed')
} else { } else {
self._deps.filesProviders[fileProvider].set(name, filesSet[file].content) self._deps.filesProviders[fileProvider].set(name, filesSet[file].content)
self.syncEditor(fileProvider + name)
} }
callback() callback()
}) })
}, (error) => { }, (error) => {
if (!error) self.switchFile()
if (callback) callback(error) if (callback) callback(error)
}) })
} }

@ -57,7 +57,7 @@ function GistHandler (_window) {
Object.keys(data.files).forEach((element) => { Object.keys(data.files).forEach((element) => {
obj['/gists/' + gistId + '/' + element] = data.files[element] obj['/gists/' + gistId + '/' + element] = data.files[element]
}) })
fileManager.setBatchFiles(obj, 'browser', (errorLoadingFile) => { fileManager.setBatchFiles(obj, 'browser', true, (errorLoadingFile) => {
if (!errorLoadingFile) { if (!errorLoadingFile) {
gistProvider.id = gistId gistProvider.id = gistId
gistProvider.origGistFiles = data.files gistProvider.origGistFiles = data.files

Loading…
Cancel
Save