Fix file extension

This commit is contained in:
HirokiUchikawa 2018-06-08 19:26:07 +09:00
parent 41a04a2849
commit c4eae3f130
1 changed files with 7 additions and 7 deletions

View File

@ -89,7 +89,7 @@ LocalFileSystem.prototype.close = function(){
LocalFileSystem.prototype.getAsync = function(scope, key) { LocalFileSystem.prototype.getAsync = function(scope, key) {
var storagePath = getStoragePath(this.storageBaseDir ,scope); var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath).then(function(data){ return loadFile(storagePath + ".json").then(function(data){
if(data){ if(data){
return util.getMessageProperty(JSON.parse(data),key); return util.getMessageProperty(JSON.parse(data),key);
}else{ }else{
@ -102,13 +102,13 @@ LocalFileSystem.prototype.getAsync = function(scope, key) {
LocalFileSystem.prototype.setAsync =function(scope, key, value) { LocalFileSystem.prototype.setAsync =function(scope, key, value) {
var storagePath = getStoragePath(this.storageBaseDir ,scope); var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath).then(function(data){ return loadFile(storagePath + ".json").then(function(data){
var obj = data ? JSON.parse(data) : {} var obj = data ? JSON.parse(data) : {}
util.setMessageProperty(obj,key,value); util.setMessageProperty(obj,key,value);
return obj; return obj;
}).then(function(obj){ }).then(function(obj){
var str = JSON.stringify(obj, undefined, 4); var str = JSON.stringify(obj, undefined, 4);
return fs.outputFile(storagePath, str, "utf8"); return fs.outputFile(storagePath + ".json", str, {encoding:"utf8",flag:"w+"});
}).catch(function(err){ }).catch(function(err){
return when.reject(err); return when.reject(err);
}); });
@ -116,7 +116,7 @@ LocalFileSystem.prototype.setAsync =function(scope, key, value) {
LocalFileSystem.prototype.keysAsync = function(scope){ LocalFileSystem.prototype.keysAsync = function(scope){
var storagePath = getStoragePath(this.storageBaseDir ,scope); var storagePath = getStoragePath(this.storageBaseDir ,scope);
return loadFile(storagePath).then(function(data){ return loadFile(storagePath + ".json").then(function(data){
if(data){ if(data){
return Object.keys(JSON.parse(data)); return Object.keys(JSON.parse(data));
}else{ }else{
@ -129,7 +129,7 @@ LocalFileSystem.prototype.keysAsync = function(scope){
LocalFileSystem.prototype.delete = function(scope){ LocalFileSystem.prototype.delete = function(scope){
var storagePath = getStoragePath(this.storageBaseDir ,scope); var storagePath = getStoragePath(this.storageBaseDir ,scope);
return fs.remove(storagePath); return fs.remove(storagePath + ".json");
} }
LocalFileSystem.prototype.clean = function(activeNodes){ LocalFileSystem.prototype.clean = function(activeNodes){
@ -148,7 +148,7 @@ LocalFileSystem.prototype.clean = function(activeNodes){
return when.reject(err); return when.reject(err);
} }
}); });
} }
module.exports = function(config){ module.exports = function(config){
return new LocalFileSystem(config); return new LocalFileSystem(config);