syntex-filesystem
Advanced tools
Comparing version 1.0.2-b10 to 1.0.2-b11
71
main.js
@@ -9,2 +9,5 @@ const fs = require('fs'), path = require('path'); | ||
{ | ||
this.running = []; | ||
this.query = {}; | ||
this.logger = platform.logger; | ||
@@ -137,23 +140,36 @@ | ||
{ | ||
if(path.parse(filePath).ext == '.json') | ||
if(!this.running.includes(filePath)) | ||
{ | ||
data = JSON.stringify(data, null, '\t'); | ||
} | ||
this.running.push(filePath); | ||
fs.writeFile(filePath, data, (error) => { | ||
if(!error) | ||
if(path.parse(filePath).ext == '.json') | ||
{ | ||
if(this.enableCache) | ||
data = JSON.stringify(data, null, '\t'); | ||
} | ||
fs.writeFile(filePath, data, (error) => { | ||
if(!error) | ||
{ | ||
cache[filePath] = JSON.stringify(JSON.parse(data)); | ||
if(this.enableCache) | ||
{ | ||
cache[filePath] = JSON.stringify(JSON.parse(data)); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
this.logger.log('error', 'bridge', 'Bridge', '[' + path.parse(filePath).base + '] %update_error%!', error); | ||
} | ||
else | ||
{ | ||
this.logger.log('error', 'bridge', 'Bridge', '[' + path.parse(filePath).base + '] %update_error%!', error); | ||
} | ||
resolve({ success : error == null, changed : true }); | ||
}); | ||
this.running.splice(this.running.indexOf(filePath), 1); | ||
resolve({ success : error == null, changed : true }); | ||
delete this.query[this._runQuery(filePath)]; | ||
}); | ||
} | ||
else | ||
{ | ||
this._addQuery({ filePath, data, resolve }); | ||
} | ||
} | ||
@@ -255,2 +271,27 @@ else | ||
} | ||
_addQuery(query) | ||
{ | ||
var id = 0, keys = Object.keys(this.query); | ||
if(keys.length > 0) | ||
{ | ||
id = parseInt(keys[keys.length - 1]) + 1; | ||
} | ||
this.query[id] = query; | ||
} | ||
_runQuery(filePath) | ||
{ | ||
for(const id in this.query) | ||
{ | ||
if(this.query[id].filePath == filePath) | ||
{ | ||
this.writeFile(this.query[id].filePath, this.query[id].data).then((response) => this.query[id].resolve(response)); | ||
return id; | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "syntex-filesystem", | ||
"version": "1.0.2-b10", | ||
"version": "1.0.2-b11", | ||
"description": "A Basic File System", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8801
258