|
|
@ -55,6 +55,7 @@ module.exports = class SharedFolder { |
|
|
|
this.type = 'localhost' |
|
|
|
this.type = 'localhost' |
|
|
|
this.error = { 'EEXIST': 'File already exists' } |
|
|
|
this.error = { 'EEXIST': 'File already exists' } |
|
|
|
this._isReady = true |
|
|
|
this._isReady = true |
|
|
|
|
|
|
|
this.filesContent = {} |
|
|
|
|
|
|
|
|
|
|
|
remixd.event.register('notified', (data) => { |
|
|
|
remixd.event.register('notified', (data) => { |
|
|
|
if (data.scope === 'sharedfolder') { |
|
|
|
if (data.scope === 'sharedfolder') { |
|
|
@ -117,10 +118,10 @@ module.exports = class SharedFolder { |
|
|
|
|
|
|
|
|
|
|
|
get (path, cb) { |
|
|
|
get (path, cb) { |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
var unprefixedpath = this.removePrefix(path) |
|
|
|
this._remixd.call('sharedfolder', 'get', {path: unprefixedpath}, (error, content) => { |
|
|
|
this._remixd.call('sharedfolder', 'get', {path: unprefixedpath}, (error, file) => { |
|
|
|
if (!error) { |
|
|
|
if (!error) { |
|
|
|
this.filesContent[path] = content |
|
|
|
this.filesContent[path] = file.content |
|
|
|
cb(error, content) |
|
|
|
cb(error, file.content) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// display the last known content.
|
|
|
|
// display the last known content.
|
|
|
|
// TODO should perhaps better warn the user that the file is not synced.
|
|
|
|
// TODO should perhaps better warn the user that the file is not synced.
|
|
|
@ -134,7 +135,6 @@ module.exports = class SharedFolder { |
|
|
|
this._remixd.call('sharedfolder', 'set', {path: unprefixedpath, content: content}, (error, result) => { |
|
|
|
this._remixd.call('sharedfolder', 'set', {path: unprefixedpath, content: content}, (error, result) => { |
|
|
|
if (cb) cb(error, result) |
|
|
|
if (cb) cb(error, result) |
|
|
|
var path = this.type + '/' + unprefixedpath |
|
|
|
var path = this.type + '/' + unprefixedpath |
|
|
|
this.filesContent[path] |
|
|
|
|
|
|
|
this.event.trigger('fileChanged', [path]) |
|
|
|
this.event.trigger('fileChanged', [path]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return true |
|
|
|
return true |
|
|
|