var async = require('async'); var semver = require('semver'); var through = require('through'); var UError = require('./error').UserError; var Local = require('./local-storage'); var Proxy = require('./up-storage'); var mystreams = require('./streams'); var utils = require('./utils'); // // Implements Storage interface // (same for storage.js, local-storage.js, up-storage.js) // function Storage(config) { if (!(this instanceof Storage)) return new Storage(config); this.config = config; // we support a number of uplinks, but only one local storage // Proxy and Local classes should have similar API interfaces this.uplinks = {}; for (var p in config.uplinks) { this.uplinks[p] = new Proxy(config.uplinks[p], config); } this.local = new Local(config); return this; } // // TODO: badly documented // Storage.prototype.add_package = function(name, metadata, callback) { var self = this; var uplinks = []; for (var i in this.uplinks) { if (this.config.proxy_access(name, i)) { uplinks.push(this.uplinks[i]); } } async.map(uplinks, function(up, cb) { up.get_package(name, function(err, res) { cb(null, [err, res]); }); }, function(err, results) { for (var i=0; i