mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-17 03:20:06 +00:00
switched to ipc through localhost
This commit is contained in:
parent
b2ba0ba1b6
commit
9ee982b53c
@ -3,6 +3,7 @@ var remotefs = remote.require("fs-extra");
|
|||||||
var dns = remote.require("dns");
|
var dns = remote.require("dns");
|
||||||
var path = remote.require("path");
|
var path = remote.require("path");
|
||||||
var dialog = remote.require("dialog");
|
var dialog = remote.require("dialog");
|
||||||
|
var net = remote.require("net");
|
||||||
var spawn = require("child_process").spawn;
|
var spawn = require("child_process").spawn;
|
||||||
|
|
||||||
var userData = remote.require("app").getPath("userData");
|
var userData = remote.require("app").getPath("userData");
|
||||||
@ -340,8 +341,25 @@ function handleCache(mode, versionString, cacheMode, callback) {
|
|||||||
"http://cdn.dexlabs.systems/ff/big" :
|
"http://cdn.dexlabs.systems/ff/big" :
|
||||||
path.dirname(versions[0].url);
|
path.dirname(versions[0].url);
|
||||||
|
|
||||||
var executable = path.join(__dirname, "lib", "cache_handler.exe");
|
var lastSizes = {};
|
||||||
var args = [
|
|
||||||
|
storageLoadingStart(versionString, cacheMode);
|
||||||
|
|
||||||
|
var server = net.createServer(function (sock) {
|
||||||
|
sock.setEncoding("utf8");
|
||||||
|
|
||||||
|
sock.on("data", function (data) {
|
||||||
|
data.split("\n").forEach(function (sizeString) {
|
||||||
|
if (sizeString === "") return;
|
||||||
|
|
||||||
|
lastSizes = JSON.parse(sizeString);
|
||||||
|
storageLoadingUpdate(lastSizes);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(0, "localhost", function () {
|
||||||
|
spawn(path.join(__dirname, "lib", "cache_handler.exe"), [
|
||||||
"--mode", (mode === "fix") ? "download" : mode,
|
"--mode", (mode === "fix") ? "download" : mode,
|
||||||
"--hash-file", hashPath,
|
"--hash-file", hashPath,
|
||||||
"--playable-root", cacheRoot,
|
"--playable-root", cacheRoot,
|
||||||
@ -349,30 +367,22 @@ function handleCache(mode, versionString, cacheMode, callback) {
|
|||||||
"--user-dir", userData,
|
"--user-dir", userData,
|
||||||
"--cdn-root", cdnRoot,
|
"--cdn-root", cdnRoot,
|
||||||
"--cache-mode", (cacheMode) ? cacheMode : "all",
|
"--cache-mode", (cacheMode) ? cacheMode : "all",
|
||||||
"--cache-version", (versionString) ? versionString : "all"
|
"--cache-version", (versionString) ? versionString : "all",
|
||||||
];
|
"--port", server.address().port
|
||||||
|
]).on("exit", function (code, signal) {
|
||||||
storageLoadingStart(versionString, cacheMode);
|
|
||||||
|
|
||||||
var child = spawn(executable, args, { stdio: [null, null, null, "ipc"] });
|
|
||||||
|
|
||||||
var lastSizes = {};
|
|
||||||
child.on("message", function (sizes) {
|
|
||||||
lastSizes = sizes;
|
|
||||||
storageLoadingUpdate(lastSizes);
|
|
||||||
});
|
|
||||||
|
|
||||||
child.on("exit", function (code, signal) {
|
|
||||||
if (code !== 0 || signal) {
|
if (code !== 0 || signal) {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(
|
||||||
"Sorry!",
|
"Sorry!",
|
||||||
"Process \"" + mode + "\" failed with code " + code + " and signal " + signal + "."
|
"Process \"" + mode + "\" failed with code " + code + " and signal " + signal + "."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.close();
|
||||||
storageLoadingComplete(lastSizes);
|
storageLoadingComplete(lastSizes);
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(lastSizes);
|
callback(lastSizes);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCacheList() {
|
function loadCacheList() {
|
||||||
|
BIN
lib/cache_handler.exe
Normal file → Executable file
BIN
lib/cache_handler.exe
Normal file → Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user