|
|
@ -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 |
|
|
|
|
|
|
|
if (isFolder) { |
|
|
|
|
|
|
|
fs.mkdirp(path).then(_ => cb()).catch(e => cb(e)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
fs.ensureFile(path).then(() => { |
|
|
|
fs.writeFile(path, args.content, 'utf8', (error, data) => { |
|
|
|
fs.writeFile(path, args.content, 'utf8', (error, data) => { |
|
|
|
if (error) console.log(error) |
|
|
|
if (error) console.log(error) |
|
|
|
cb(error, data) |
|
|
|
cb(error, data) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
}).catch(e => cb(e)) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
rename: function (args, cb) { |
|
|
|
rename: function (args, cb) { |
|
|
|