Skip to content

Commit

Permalink
gist edit
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus committed Sep 30, 2019
1 parent f14f7ab commit 4e735ee
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/app/files/file-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ fileExplorer.prototype.toGist = function (id) {
}
}

this.packageFiles(this.files, (error, packaged) => {
this.packageFiles(this.files, 'browser/gists/' + id, (error, packaged) => {
if (error) {
console.log(error)
modalDialogCustom.alert('Failed to create gist: ' + error)
Expand Down Expand Up @@ -507,21 +507,19 @@ fileExplorer.prototype.toGist = function (id) {
}

// return all the files, except the temporary/readonly ones..
fileExplorer.prototype.packageFiles = function (filesProvider, callback) {
fileExplorer.prototype.packageFiles = function (filesProvider, directory, callback) {
var ret = {}
filesProvider.resolveDirectory('/', (error, files) => {
filesProvider.resolveDirectory(directory, (error, files) => {
if (error) callback(error)
else {
async.eachSeries(Object.keys(files), (path, cb) => {
filesProvider.get(path, (error, content) => {
if (error) cb(error)
else if (/^\s+$/.test(content) || !content.length) {
if (error) return cb(error)
if (/^\s+$/.test(content) || !content.length) {
content = '// this line is added to create a gist. Empty file is not allowed.'
if (!error) {
ret[path] = { content }
cb()
}
}
ret[path] = { content }
cb()
})
}, (error) => {
callback(error, ret)
Expand All @@ -543,7 +541,7 @@ fileExplorer.prototype.copyFiles = function () {
)
function doCopy (target) {
// package only files from the browser storage.
self.packageFiles(self.files, (error, packaged) => {
self.packageFiles(self.files, '/', (error, packaged) => {
if (error) {
console.log(error)
} else {
Expand Down

0 comments on commit 4e735ee

Please sign in to comment.