fix set folder / files

pull/3094/head
yann300 5 years ago
parent f5e2278c5b
commit e1855ddace
  1. 15
      src/services/sharedFolder.js

@ -69,6 +69,7 @@ module.exports = {
set: function (args, cb) { set: function (args, cb) {
if (this.readOnly) return cb('Cannot write file: read-only mode selected') if (this.readOnly) return cb('Cannot write file: read-only mode selected')
const isFolder = args.path.endsWith('/')
var path = utils.absolutePath(args.path, this.sharedFolder) var path = utils.absolutePath(args.path, this.sharedFolder)
if (fs.existsSync(path) && !isRealPath(path, cb)) return if (fs.existsSync(path) && !isRealPath(path, cb)) return
if (args.content === 'undefined') { // no !!!!! if (args.content === 'undefined') { // no !!!!!
@ -76,10 +77,16 @@ module.exports = {
return return
} }
this.trackDownStreamUpdate[path] = path this.trackDownStreamUpdate[path] = path
fs.writeFile(path, args.content, 'utf8', (error, data) => { if (isFolder) {
if (error) console.log(error) fs.mkdirp(path).then(_ => cb()).catch(e => cb(e))
cb(error, data) } else {
}) fs.ensureFile(path).then(() => {
fs.writeFile(path, args.content, 'utf8', (error, data) => {
if (error) console.log(error)
cb(error, data)
})
}).catch(e => cb(e))
}
}, },
rename: function (args, cb) { rename: function (args, cb) {

Loading…
Cancel
Save