Merge pull request #49 from Dahlgren/bugfix/remove-unused-mod-traverse

Removed unused mod folder traversal
This commit is contained in:
Björn Dahlgren 2017-04-01 10:40:58 +02:00 committed by GitHub
commit 100c38df6f
4 changed files with 0 additions and 67 deletions

View File

@ -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;

View File

@ -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);
});
};

View File

@ -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": {

View File

@ -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, {});