mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Merge pull request #49 from Dahlgren/bugfix/remove-unused-mod-traverse
Removed unused mod folder traversal
This commit is contained in:
commit
100c38df6f
@ -6,8 +6,6 @@ var _ = require('lodash');
|
||||
var path = require('path');
|
||||
var playwithsix = require('playwithsix');
|
||||
|
||||
var traverse = require('./mods/traverse');
|
||||
|
||||
var Mods = function (config) {
|
||||
this.config = config;
|
||||
this.liteMods = true;
|
||||
@ -148,8 +146,4 @@ Mods.prototype.search = function (query, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
Mods.prototype.traverse = function (mod, cb) {
|
||||
traverse(path.join(this.config.path, mod), cb);
|
||||
};
|
||||
|
||||
module.exports = Mods;
|
||||
|
@ -1,49 +0,0 @@
|
||||
var nodefn = require('when/node/function');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var when = require('when');
|
||||
|
||||
function walk (directory) {
|
||||
createFile = function (file, stat) {
|
||||
return {
|
||||
type: "file",
|
||||
name: file,
|
||||
size: stat.size
|
||||
};
|
||||
};
|
||||
|
||||
createFolder = function (folder) {
|
||||
return {
|
||||
type: "folder",
|
||||
name: folder,
|
||||
files: []
|
||||
};
|
||||
};
|
||||
|
||||
var results = [];
|
||||
|
||||
return when.map(nodefn.call(fs.readdir, directory), function(file) {
|
||||
var absolutePath = path.join(directory, file);
|
||||
return nodefn.call(fs.stat, absolutePath).then(function(stat) {
|
||||
if (stat.isFile()) {
|
||||
return results.push(createFile(file, stat));
|
||||
}
|
||||
|
||||
folder = createFolder(file);
|
||||
return walk(absolutePath).then(function(filesInDir) {
|
||||
folder.files = filesInDir;
|
||||
results.push(folder);
|
||||
});
|
||||
});
|
||||
}).then(function() {
|
||||
return results;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function (path, cb) {
|
||||
walk(path).then(function(files) {
|
||||
cb(null, files);
|
||||
}).otherwise(function(error) {
|
||||
cb(error);
|
||||
});
|
||||
};
|
@ -23,7 +23,6 @@
|
||||
"socket.io": "^1.0.4",
|
||||
"steam-workshop": "0.0.1",
|
||||
"userhome": "^1.0.0",
|
||||
"when": "~3.1.0",
|
||||
"winser": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -9,17 +9,6 @@ module.exports = function (modsManager) {
|
||||
res.send(204, {});
|
||||
},
|
||||
|
||||
show: function(req, res){
|
||||
modsManager.traverse(req.params.mod, function (err, files) {
|
||||
if (err || !files) {
|
||||
console.error(err.stack || err);
|
||||
res.send(500, err);
|
||||
} else {
|
||||
res.json(files);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update: function(req, res){
|
||||
modsManager.download(req.params.mod);
|
||||
res.send(204, {});
|
||||
|
Loading…
Reference in New Issue
Block a user