Bisa / factorio-init

Factorio init script
MIT License
414 stars 82 forks source link

Missing Content-Disposition header causes install script to fail #194

Closed MisterPhilip closed 2 years ago

MisterPhilip commented 2 years ago

It appears that one of the headers that was used to grab the file name no longer exists from the download URLs.

When running install (or update, if manually installed), this is the output:

factorio@factorio:/opt/factorio-init$ ./factorio install
DEBUG: Check/Loading config defaults for command 'install'
DEBUG: Skip check/loading defaults for command 'install'
DEBUG: Checking for latest headless version.
DEBUG: Found, latest version: ''
DEBUG: as_user: test -w "/tmp"}
DEBUG: No cache hit for ''.
DEBUG: as_user: wget -O "/tmp/" "https://www.factorio.com/get-download/stable/headless/linux64"}
/tmp/: Is a directory
Aborting install, unable to download & cache '/tmp/'.

Running curl against the latest URL these are the headers returned:

factorio@factorio:/opt/factorio-init$ curl -LIs "https://www.factorio.com/get-download/stable/headless/linux64"
HTTP/2 302
date: Wed, 09 Mar 2022 03:04:31 GMT
content-type: text/html; charset=utf-8
content-length: 424
location: https://dl.factorio.com/releases/factorio_headless_x64_1.1.53.tar.xz?secure=HEdDYInwVHq2GXeT8aqxIw,1646798671
x-frame-options: SAMEORIGIN
vary: Accept-Encoding, Cookie
strict-transport-security: max-age=31536000
set-cookie: session=eyJ2aXNpdG9yX2lkIjoiNGZjZDg0MmNlYzMzZDM3OSJ9.YigZPw.A9WNfVCTnuafxVwwxpnSO3xTH5g; Domain=.factorio.com; Secure; HttpOnly; Path=/
via: 1.1 vegur
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2B%2F%2BQpBB36wi5TRMwSggGx82EabQqA2H%2F6HeJVZ0eDLmqygJhLkNErzcGTrt1UZnFH%2FBZhjhMCoxEC69AbMboH64CsT2XgBmPiSbRdcUMnQtKhBe9sFzYQZwo6s7DfHhE1uyM%2B7Kmuiq5XBgWfuk%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 6e9095692a207c50-LAX

HTTP/2 200
date: Wed, 09 Mar 2022 03:04:31 GMT
content-type: application/octet-stream
content-length: 52117820
last-modified: Wed, 19 Jan 2022 10:33:59 GMT
etag: "61e7e917-31b413c"
access-control-allow-origin: *
x-accel-expires: @1647266797
server: CDN77-Turbo
x-77-nzt: AVm7uwoa2An/Up8IAA
x-77-nzt-ray: lpBG9iC6pu0
x-cache: HIT
x-age: 565074
x-77-pop: losangelesUSCA
x-77-cache: HIT
accept-ranges: bytes

It looks like the code is expecting Content-Disposition, which doesn't exist anymore. https://github.com/Bisa/factorio-init/blob/35d82197d67e73491475ddfc6bbb005a19633d5c/factorio#L484

I've tried from a few different computers, including a friend in another state and they also were not seeing the header on the request.

imakiro commented 2 years ago

@MisterPhilip hi, by any chance, did you find a workaround ?

MisterPhilip commented 2 years ago

@imakiro - I did not; I ended up installing Factorio directly from the tarball (https://www.factorio.com/get-download/stable/headless/linux64)

imakiro commented 2 years ago

Ok, thanks to @greenblood , I fixed it in my branch : https://github.com/imakiro/factorio-init/tree/fix-install relevant code part : https://github.com/imakiro/factorio-init/commit/f1448f470167a4697a0c57a6dc5b6f39f1f34db1

Legrems commented 2 years ago

Hello, i will make a PR using the api to fetch the latest release: https://wiki.factorio.com/Download_API https://factorio.com/api/latest-releases

(something like this) image