Skip to content

Commit 54a7532

Browse files
author
Jan B
committed
add '--no-https' to legendary args for LanCache compatibility
This flag can be enabled via the advanced settings and gets applied to the uses of legendary commands "install", "update" and "repair".
1 parent 14a7cd3 commit 54a7532

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

electron/legendary/games.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,13 @@ class LegendaryGame extends Game {
293293
status: 'updating'
294294
})
295295
const { maxWorkers } = await GlobalConfig.get().getSettings()
296+
const { downloadNoHttps } = await GlobalConfig.get().getSettings()
296297
const info = await Game.get(this.appName, 'legendary').getInstallInfo()
297298
const workers = maxWorkers ? ['--max-workers', `${maxWorkers}`] : []
299+
const noHttps = downloadNoHttps ? ['--no-https'] : []
298300
const logPath = join(heroicGamesConfigPath, this.appName + '.log')
299301

300-
const commandParts = ['update', this.appName, ...workers, '-y']
302+
const commandParts = ['update', this.appName, ...workers, ...noHttps, '-y']
301303
const command = getLegendaryCommand(commandParts)
302304

303305
logInfo([`Updating ${this.appName} with:`, command], LogPrefix.Legendary)
@@ -370,10 +372,12 @@ class LegendaryGame extends Game {
370372
platformToInstall
371373
}: InstallArgs): Promise<{ status: 'done' | 'error' }> {
372374
const { maxWorkers } = await GlobalConfig.get().getSettings()
375+
const { downloadNoHttps } = await GlobalConfig.get().getSettings()
373376
const info = await Game.get(this.appName, 'legendary').getInstallInfo(
374377
platformToInstall
375378
)
376379
const workers = maxWorkers ? ['--max-workers', `${maxWorkers}`] : []
380+
const noHttps = downloadNoHttps ? ['--no-https'] : []
377381
const withDlcs = installDlcs ? '--with-dlcs' : '--skip-dlcs'
378382
const installSdl = sdlList.length
379383
? this.getSdlList(sdlList)
@@ -391,6 +395,7 @@ class LegendaryGame extends Game {
391395
withDlcs,
392396
...installSdl,
393397
...workers,
398+
...noHttps,
394399
'-y'
395400
]
396401
const command = getLegendaryCommand(commandParts)
@@ -458,11 +463,13 @@ class LegendaryGame extends Game {
458463
public async repair(): Promise<ExecResult> {
459464
// this.state.status = 'repairing'
460465
const { maxWorkers } = await GlobalConfig.get().getSettings()
466+
const { downloadNoHttps } = await GlobalConfig.get().getSettings()
461467
const workers = maxWorkers ? ['--max-workers', `${maxWorkers}`] : []
468+
const noHttps = downloadNoHttps ? ['--no-https'] : []
462469

463470
const logPath = join(heroicGamesConfigPath, this.appName + '.log')
464471

465-
const commandParts = ['repair', this.appName, ...workers, '-y']
472+
const commandParts = ['repair', this.appName, ...workers, ...noHttps, '-y']
466473
const command = getLegendaryCommand(commandParts)
467474

468475
logInfo([`Repairing ${this.appName}:`, command], LogPrefix.Legendary)

electron/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface AppSettings {
2222
defaultInstallPath: string
2323
disableController: boolean
2424
discordRPC: boolean
25+
downloadNoHttps: boolean
2526
egsLinkedPath: string
2627
exitToTray: boolean
2728
enableEsync: boolean

src/screens/Settings/components/AdvancedSettings/index.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import classNames from 'classnames'
88
import { IpcRenderer, Clipboard } from 'electron'
99
import { useTranslation } from 'react-i18next'
10+
import { ToggleSwitch } from 'src/components/UI'
1011
import React, { useEffect, useState } from 'react'
1112
import { AppSettings, Path } from 'src/types'
1213
import { configStore } from 'src/helpers/electronStores'
@@ -24,16 +25,20 @@ const { ipcRenderer, clipboard } = window.require('electron') as ElectronProps
2425
interface Props {
2526
altLegendaryBin: string
2627
altGogdlBin: string
28+
downloadNoHttps: boolean
2729
setAltLegendaryBin: (value: string) => void
2830
setAltGogdlBin: (value: string) => void
31+
toggleDownloadNoHttps: () => void
2932
settingsToSave: AppSettings
3033
}
3134

3235
export const AdvancedSettings = ({
3336
altLegendaryBin,
3437
altGogdlBin,
38+
downloadNoHttps,
3539
setAltLegendaryBin,
3640
setAltGogdlBin,
41+
toggleDownloadNoHttps,
3742
settingsToSave
3843
}: Props) => {
3944
const [legendaryVersion, setLegendaryVersion] = useState('')
@@ -210,6 +215,16 @@ export const AdvancedSettings = ({
210215
}
211216
/>
212217

218+
<ToggleSwitch
219+
htmlId="downloadNoHttps"
220+
value={downloadNoHttps}
221+
handleChange={toggleDownloadNoHttps}
222+
title={t(
223+
'setting.download-no-https',
224+
'Download games without HTTPS (useful for CDNs e.g. LanCache)'
225+
)}
226+
/>
227+
213228
<div className="footerFlex">
214229
<button
215230
className={classNames('button', 'is-footer', {

src/screens/Settings/index.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ function Settings() {
176176
toggle: toggleDisableController,
177177
setOn: setDisableController
178178
} = useToggle(false)
179+
const {
180+
on: downloadNoHttps,
181+
toggle: toggleDownloadNoHttps,
182+
setOn: setDownloadNoHttps
183+
} = useToggle(false)
179184

180185
const [autoSyncSaves, setAutoSyncSaves] = useState(false)
181186
const [altWine, setAltWine] = useState([] as WineInstallation[])
@@ -236,6 +241,7 @@ function Settings() {
236241
setDefaultWinePrefix(config.defaultWinePrefix)
237242
setUseSteamRuntime(config.useSteamRuntime)
238243
setDisableController(config.disableController || false)
244+
setDownloadNoHttps(config.downloadNoHttps)
239245

240246
if (!isDefault) {
241247
const { title: gameTitle, canRunOffline: can_run_offline } =
@@ -267,6 +273,7 @@ function Settings() {
267273
defaultWinePrefix,
268274
disableController,
269275
discordRPC,
276+
downloadNoHttps,
270277
egsLinkedPath,
271278
enableEsync,
272279
enableFsync,
@@ -473,6 +480,8 @@ function Settings() {
473480
setAltLegendaryBin={setAltLegendaryBin}
474481
altGogdlBin={altGogdlBin}
475482
setAltGogdlBin={setAltGogdlBin}
483+
downloadNoHttps={downloadNoHttps}
484+
toggleDownloadNoHttps={toggleDownloadNoHttps}
476485
settingsToSave={settingsToSave}
477486
/>
478487
)}

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface AppSettings {
1818
defaultInstallPath: string
1919
disableController: boolean
2020
discordRPC: boolean
21+
downloadNoHttps: boolean
2122
egsLinkedPath: string
2223
exitToTray: boolean
2324
enableEsync: boolean

0 commit comments

Comments
 (0)