Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use an in-memory cache so branches don't get downloaded twice #40

Open
matthewmueller opened this issue Aug 18, 2014 · 1 comment
Open

Comments

@matthewmueller
Copy link
Contributor

Since we're not caching branches like master, we're fetching these packages twice.

@frankwallis
Copy link

I'm not sure if this is related but I believe this is an error:

Package.prototype.fetch = unyield(function *() {

  // resolve
  var ref = this.resolved || (yield this.resolve());
  var token = this.tok ? this.tok + '@' : '';
  var url = fmt('https://%sgithub.com/%s/archive/%s.tar.gz', token, this.repo, ref);
  var cache = join(cachepath, this.slug() + '.tar.gz');
  var dest = this.path();

  // inflight, wait till other package completes
  if (inflight[dest]) {
    var pkg = inflight[dest];
    yield function(done){ pkg.once('fetch', done); };
  }

  // set package as inflight
  inflight[dest] = this;

  // check if directory already exists
  if (yield this.exists()) {

If two things are waiting on the event emitter then when it fires they will both run at the same time. I think it needs to use while:

// inflight, wait till other package completes
  while (inflight[dest]) {
    var pkg = inflight[dest];
    yield function(done){ pkg.once('fetch', done); };
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants