Skip to content

Commit

Permalink
Update 1.4.2
Browse files Browse the repository at this point in the history
- Increase mod download timeout
- Fix encoding urls
- Cloudflare fix and initial support for mac arm64
  • Loading branch information
tribbedev committed Jul 17, 2022
1 parent 2e73761 commit 1484e9a
Show file tree
Hide file tree
Showing 8 changed files with 552 additions and 249 deletions.
740 changes: 509 additions & 231 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rplauncher",
"version": "1.4.1",
"version": "1.4.2",
"description": "rPLauncher is simple, yet powerful Minecraft custom launcher with a strong focus on the user experience",
"keywords": [
"minecraft",
Expand Down Expand Up @@ -74,7 +74,8 @@
"node": ">=14.16.0"
},
"cpu": [
"x64"
"x64",
"arm64"
],
"browserslist": {
"production": [
Expand Down Expand Up @@ -118,8 +119,8 @@
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"electron": "^19.0.4",
"electron-builder": "^22.14.5",
"electron-updater": "^4.6.1",
"electron-builder": "^23.0.3",
"electron-updater": "^5.0.1",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
Expand Down
29 changes: 22 additions & 7 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,12 @@ function createWindow() {

app.on('ready', createWindow);

app.on('window-all-closed', () => {
app.on('window-all-closed', async () => {
if (watcher) {
watcher.stop();
await watcher.stop();
watcher = null;
}
if (process.platform !== 'darwin') {
app.quit();
}
app.quit();
});

app.on('before-quit', async () => {
Expand Down Expand Up @@ -622,8 +620,22 @@ ipcMain.handle('shutdown-discord-rpc', () => {
discordRPC.shutdownRPC();
});

const removeOriginHeader = (details, callback) => {
// Use a header to skip sending Origin on request.
const {
'X-Skip-Origin': xSkipOrigin,
Origin: _origin,
...requestHeaders
} = details.requestHeaders;
delete requestHeaders.Origin;
callback({ cancel: false, requestHeaders });
};

ipcMain.handle('download-optedout-mod', async (e, { url, filePath }) => {
let win = new BrowserWindow();
win.webContents.openDevTools();

win.webContents.session.webRequest.onBeforeSendHeaders(removeOriginHeader);

const mainWindowListener = () => {
if (win) {
Expand Down Expand Up @@ -671,7 +683,7 @@ ipcMain.handle('download-optedout-mod', async (e, { url, filePath }) => {
};
const timer = setTimeout(
() => cleanupFn(`Download for ${url} timed out`),
40000
60 * 1000 * 10
);
win.webContents.session.once('will-download', (_, item) => {
item.setSavePath(filePath);
Expand Down Expand Up @@ -715,6 +727,9 @@ ipcMain.handle('download-optedout-mod', async (e, { url, filePath }) => {

ipcMain.handle('download-optedout-mods', async (e, { mods, instancePath }) => {
let win = new BrowserWindow();
win.webContents.openDevTools();

win.webContents.session.webRequest.onBeforeSendHeaders(removeOriginHeader);

const mainWindowListener = () => {
if (win) {
Expand Down Expand Up @@ -767,7 +782,7 @@ ipcMain.handle('download-optedout-mods', async (e, { mods, instancePath }) => {
};
const timer = setTimeout(
() => cleanupFn(`Download for ${modManifest.fileName} timed out`),
40000
60 * 1000 * 10
);

const isResourcePack = addon.classId === 12;
Expand Down
Binary file added public/native/darwin/murmur2_aarch64.node
Binary file not shown.
Binary file added public/native/darwin/nsfw_aarch64.node
Binary file not shown.
6 changes: 5 additions & 1 deletion public/native/murmur2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ if (os.platform() === 'win32') {
} else if (os.platform() === 'linux') {
addon = require('./linux/murmur2.node');
} else if (os.platform() === 'darwin') {
addon = require('./darwin/murmur2.node');
if (os.arch() === 'arm64') {
addon = require('./darwin/murmur2_aarch64.node');
} else {
addon = require('./darwin/murmur2.node');
}
}

const addonPromise = filePath => {
Expand Down
6 changes: 5 additions & 1 deletion public/native/nsfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ if (os.platform() === 'win32') {
} else if (os.platform() === 'linux') {
NSFW = require('./linux/nsfw.node');
} else if (os.platform() === 'darwin') {
NSFW = require('./darwin/nsfw.node');
if (os.arch() === 'arm64') {
NSFW = require('./darwin/nsfw_aarch64.node');
} else {
NSFW = require('./darwin/nsfw.node');
}
}

function NSFWFilePoller(watchPath, eventCallback, debounceMS) {
Expand Down
11 changes: 6 additions & 5 deletions src/app/desktop/utils/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import computeFileHash from './computeFileHash';

const fs = fss.promises;

function isEncoded(uri) {
return uri !== decodeURIComponent(uri);
function getUri(url) {
return new URL(url).href;
}

export const downloadInstanceFiles = async (
Expand Down Expand Up @@ -57,6 +57,7 @@ export const downloadInstanceFiles = async (
};

const downloadFileInstance = async (fileName, url, sha1, legacyPath) => {
let encodedUrl;
try {
const filePath = path.dirname(fileName);
try {
Expand All @@ -72,7 +73,7 @@ const downloadFileInstance = async (fileName, url, sha1, legacyPath) => {
if (legacyPath) await makeDir(path.dirname(legacyPath));
}

const encodedUrl = isEncoded ? url : encodeURI(url);
encodedUrl = getUri(url);

const { data } = await axios.get(encodedUrl, {
responseType: 'stream',
Expand Down Expand Up @@ -111,7 +112,7 @@ const downloadFileInstance = async (fileName, url, sha1, legacyPath) => {
return true;
} catch (e) {
console.error(
`Error while downloading <${url}> to <${fileName}> --> ${e.message}`
`Error while downloading <${url} | ${encodedUrl}> to <${fileName}> --> ${e.message}`
);
return false;
}
Expand All @@ -120,7 +121,7 @@ const downloadFileInstance = async (fileName, url, sha1, legacyPath) => {
export const downloadFile = async (fileName, url, onProgress) => {
await makeDir(path.dirname(fileName));

const encodedUrl = isEncoded ? url : encodeURI(url);
const encodedUrl = getUri(url);

const { data, headers } = await axios.get(encodedUrl, {
responseType: 'stream',
Expand Down

0 comments on commit 1484e9a

Please sign in to comment.