Optimized server state updating (update file without listing directory)
This commit is contained in:
parent
3821cef116
commit
dac1add279
@ -153,15 +153,16 @@ export function Client(cid, secret) {
|
|||||||
|
|
||||||
this.remotestate = reactive({});
|
this.remotestate = reactive({});
|
||||||
this.setup_remotestate = async () => {
|
this.setup_remotestate = async () => {
|
||||||
var fs = await this.encfs();
|
var fs = await this.encfs(), file;
|
||||||
try {
|
try {
|
||||||
Object.assign(this.remotestate, JSON.parse(await fs.cat('state')));
|
file = await fs.open('state');
|
||||||
|
Object.assign(this.remotestate, JSON.parse(await file.cat(null)));
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
console.error(ex);
|
console.error(ex);
|
||||||
await fs.create('state', JSON.stringify(this.remotestate));
|
file = await fs.create('state', JSON.stringify(this.remotestate));
|
||||||
}
|
}
|
||||||
watch(this.remotestate, debounce(function(value) {
|
watch(this.remotestate, debounce(function(value) {
|
||||||
fs.update('state', JSON.stringify(value));
|
file.update(null, JSON.stringify(value));
|
||||||
}, 1000), { deep: true });
|
}, 1000), { deep: true });
|
||||||
if((!this.remotestate.resources) && (localstate.resources)) this.remotestate.resources = localstate.resources;
|
if((!this.remotestate.resources) && (localstate.resources)) this.remotestate.resources = localstate.resources;
|
||||||
if((!this.remotestate.practitioner) && (localstate.practitioner)) this.remotestate.practitioner = localstate.practitioner;
|
if((!this.remotestate.practitioner) && (localstate.practitioner)) this.remotestate.practitioner = localstate.practitioner;
|
||||||
|
Loading…
Reference in New Issue
Block a user