Mercurial > psgxs
diff backends/directory.js @ 55:fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 25 Jul 2011 17:35:32 -0700 |
parents | 023f767662d3 |
children | 99bd1d1ac071 |
line wrap: on
line diff
--- a/backends/directory.js +++ b/backends/directory.js @@ -25,7 +25,7 @@ var backend = exports; backend.save = function(dir) { if (!dir) - dir = 'storage'; + dir = 'data'; fs.stat(dir, function(err, stats) { if (err) @@ -57,7 +57,7 @@ backend.save = function(dir) { var inspect = require('sys').inspect; for (var nodeID in data) - fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null)); + fs.writeFile(dir+'/'+encodeURI(nodeID).replace('/', '%2f')+'.json', inspect(data[nodeID], false, null)); var toDelete = []; @@ -68,14 +68,14 @@ backend.save = function(dir) { } for (var nodeID in toDelete) - fs.unlink(dir+'/'+toDelete[nodeID]); + fs.unlink(dir+'/'+encodeURI(toDelete[nodeID]).replace('/', '%2f')); }); }); } backend.load = function(dir) { if (!dir) - dir = 'storage'; + dir = 'data'; fs.stat(dir, function(err, stats) { if (err) @@ -120,7 +120,7 @@ backend.load = function(dir) { if (/^\./.test(file)) continue; - var nodeID = file.replace(/\.json$/, ''); + var nodeID = decodeURI(file.replace(/\.json$/, '').replace('%2f', '/')); var data = fs.readFileSync(dir+'/'+file).toString();