Mercurial > psgxs
comparison backends/directory.js @ 30:b2faacfefb90
Rewrite of the module manager; fix of some modules; fix of the directory backend.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 04 Nov 2010 17:50:52 +0100 |
parents | e007a6364bf0 |
children | 62cbb1c49bc5 |
comparison
equal
deleted
inserted
replaced
29:e007a6364bf0 | 30:b2faacfefb90 |
---|---|
52 } | 52 } |
53 var data = sanitize(backend.list); | 53 var data = sanitize(backend.list); |
54 | 54 |
55 var inspect = require('sys').inspect; | 55 var inspect = require('sys').inspect; |
56 | 56 |
57 for (var nodeID in data) | |
58 fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null)); | |
59 | |
57 var toDelete = []; | 60 var toDelete = []; |
58 | 61 |
59 for (var i in files) { | 62 for (var i in files) { |
60 var nodeID = files[i]; | 63 var file = files[i]; |
61 if (nodeID in data) { | 64 if (!(file.replace(/\.json$/, '') in data)) |
62 fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null)); | 65 toDelete.push(file); |
63 delete data[nodeID]; | |
64 } else | |
65 toDelete.push(nodeID); | |
66 } | 66 } |
67 | 67 |
68 for (var nodeID in data) { | 68 for (var nodeID in toDelete) |
69 inspect(nodeID); | 69 fs.unlink(dir+'/'+toDelete[nodeID]); |
70 inspect(data[nodeID]); | |
71 fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null)); | |
72 } | |
73 | |
74 for (var nodeID in toDelete) { | |
75 fs.unlink(toDelete[nodeID]); | |
76 } | |
77 }); | 70 }); |
78 }); | 71 }); |
79 } | 72 } |
80 | 73 |
81 backend.load = function(dir) { | 74 backend.load = function(dir) { |