Skip to content

Commit

Permalink
Merge pull request lix-pm#196 from gene-pavlovsky/improve-concurrent-…
Browse files Browse the repository at this point in the history
…download-safety

Add process PID to download dirname
  • Loading branch information
back2dos authored Aug 9, 2024
2 parents a72452e + 7fc714e commit d89bb73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/lix/client/Libraries.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package lix.client;

import lix.client.sources.*;
import haxe.DynamicAccess;
import lix.client.Archives;
import lix.api.Api;
import haxeshim.Scope.*;
import lix.api.Api;
import lix.client.Archives;

using haxe.Json;

Expand Down Expand Up @@ -45,7 +44,7 @@ using haxe.Json;
}
else {
logger.info('${if (exists) "forcedly redownloading" else "downloading"} ${a.normalized}');
var dest = scope.haxeshimRoot + '/downloads/download@' + Date.now().getTime();
final dest = '${scope.haxeshimRoot}/downloads/download@${Math.floor(Date.now().getTime())}_${js.Node.process.pid}';
(switch a.kind {
case null: Download.archive(a.url, 0, dest, logger);
case Zip: Download.zip(a.url, 0, dest, logger);
Expand Down Expand Up @@ -299,4 +298,4 @@ using haxe.Json;
.next(saveHxml)
.next(_ => exec('post install', infos.postInstall));
});
}
}
3 changes: 2 additions & 1 deletion src/lix/client/sources/Haxelib.hx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ using tink.CoreApi;
return Future.async(function (cb) {
var cnx = haxe.remoting.HttpAsyncConnection.urlConnect(resolve('/api/3.0/index.n', options));
cnx.setErrorHandler(function (e) cb(Failure(Error.withData('Failed to get version information from haxelib because $e', e))));

var repo = new Proxy(cnx.resolve('api'));
repo.infos(name, function (s) cb(Success(s)));
});

}
}

0 comments on commit d89bb73

Please sign in to comment.