From c31671d1e6d45cf84f68efdd8c4368f2cd973a7a Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:53:34 +0000 Subject: [PATCH] Added 2.0 zip file name to version matcher (#671) * Added 2.0 zip file name to version matcher Fixes: Install problem ? #668 * Add changelog entry for 671. --- CHANGELOG.md | 1 + packages/create/create.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64951976..4848d8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Many thanks to the following for contributing to this release: - Added `controller.factorio_username` and `controller.factorio_token` config to set Factorio credentials used for the whole cluster. - Added `controller.share_factorio_credential_with_hosts` config to optionally require hosts to provide their own credentials. - Added `host.factorio_username` and `host.factorio_token` config to set Factorio credentials used on a given host. +- Fixed 2.0 version extraction from linux headless downloaded during installation of clusterio. [#671](https://github.com/clusterio/clusterio/pull/671) ### Breaking Changes diff --git a/packages/create/create.js b/packages/create/create.js index 7a2291e2..7a7eaaad 100755 --- a/packages/create/create.js +++ b/packages/create/create.js @@ -746,7 +746,11 @@ async function downloadLinuxServer() { const url = new URL(res.headers.location); // get the filename of the latest factorio archive from redirected url const filename = path.posix.basename(url.pathname); - const version = filename.match(/(?<=factorio_headless_x64_).*(?=\.tar\.xz)/)[0]; + const match = filename.match(/(?<=factorio_headless_x64_|factorio-headless_linux_)\d+\.\d+\.\d+(?=\.tar\.xz)/); + if (!match || !match.length) { + throw Error(`Unable to extract version from filename: ${filename}`); + } + const version = match[0]; const tmpDir = "temp/create-temp/"; const archivePath = tmpDir + filename;