Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ backends.forEach(function(name) {
return;//break

var backend = require("./backends/"+name);

var vars = backend.vars;

if(!backend.init)
Expand Down Expand Up @@ -66,9 +66,5 @@ backends.forEach(function(name) {

if(!matched)
exit("No backend match. "+
"Environment variables missing for: " +
"Environment variables missing for: " +
backends.join(", "));




18 changes: 11 additions & 7 deletions lib/backends/mega.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -172,4 +176,4 @@ function getPath(f) {
f = f.parent;
}
return path;
}
}
3 changes: 1 addition & 2 deletions lib/torrents.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var events = require('events');
var torrents = module.exports = new events.EventEmitter();

Expand Down Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
},
"engines": {
"node": ">=0.10.x"
},
"devDependencies": {
"nodemon": "^1.11.0"
}
}
10 changes: 5 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down