diff --git a/lib/backend.js b/lib/backend.js index 7f5b7a9..678e89d 100644 --- a/lib/backend.js +++ b/lib/backend.js @@ -24,7 +24,7 @@ backends.forEach(function(name) { return;//break var backend = require("./backends/"+name); - + var vars = backend.vars; if(!backend.init) @@ -66,9 +66,5 @@ backends.forEach(function(name) { if(!matched) exit("No backend match. "+ - "Environment variables missing for: " + + "Environment variables missing for: " + backends.join(", ")); - - - - diff --git a/lib/backends/mega.js b/lib/backends/mega.js index d4d19da..358add6 100644 --- a/lib/backends/mega.js +++ b/lib/backends/mega.js @@ -26,17 +26,21 @@ exports.upload = function(torrentFile, callback) { if(!storage.root) callback("Not ready"); - var dirs = torrentFile.path.split("/"); + var dirs = torrentFile.path.split("\\") || torrentFile.path.split("/") || torrentFile.path; var name = dirs.pop(); var dir = null; var root = storage.root; //call back when all dirs made - mkdirp(dirs, root, function(err, dir) { - if(err) - return callback(err); - upload(dir); - }); + if(dirs.length != 0){ + mkdirp(dirs, root, function(err, dir) { + if(err) + return callback(err); + upload(dir); + }); + }else{ + upload(root) + } //before we can upload, we need to mkdirp function mkdirp(dirs, parent, cb) { @@ -172,4 +176,4 @@ function getPath(f) { f = f.parent; } return path; -} \ No newline at end of file +} diff --git a/lib/torrents.js b/lib/torrents.js index 81f90f9..f85d033 100644 --- a/lib/torrents.js +++ b/lib/torrents.js @@ -1,4 +1,3 @@ - var events = require('events'); var torrents = module.exports = new events.EventEmitter(); @@ -157,7 +156,7 @@ torrents.load = function(data, callback) { } catch(e) { return callback("Failed to parse torrent"); } - load(t, callback); + load(t, callback); }); } else { return callback("Invalid request"); diff --git a/package.json b/package.json index 314bccf..090c463 100644 --- a/package.json +++ b/package.json @@ -29,5 +29,8 @@ }, "engines": { "node": ">=0.10.x" + }, + "devDependencies": { + "nodemon": "^1.11.0" } } diff --git a/server.js b/server.js index 8b6ebc1..11fde87 100644 --- a/server.js +++ b/server.js @@ -20,11 +20,11 @@ var http = require('http'); var express = require('express'); var app = express(); var server = http.createServer(app); -var port = parseInt(process.argv[2], 10) || - process.env.PORT || - process.env.OPENSHIFT_NODEJS_PORT || - 3000; -var host = process.env.HOST || +var port = process.env.PORT || + process.env.OPENSHIFT_NODEJS_PORT || + parseInt(process.argv[2], 10) || + 8080 +var host = process.env.HOST || process.env.OPENSHIFT_NODEJS_IP || "0.0.0.0";