Skip to content

Commit fa4c827

Browse files
authored
[bg3] check fewer files in lslib, but extract all files from Packed/Tools
1 parent fda5d6a commit fa4c827

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

games/baldursgate3/lslib_retriever.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ def _needed_lslib_files(self):
2525
"Divine.dll.config",
2626
"Divine.exe",
2727
"Divine.runtimeconfig.json",
28-
"K4os.Compression.LZ4.dll",
29-
"K4os.Compression.LZ4.Streams.dll",
30-
"LSLib.dll",
31-
"LSLibNative.dll",
32-
"LZ4.dll",
33-
"Newtonsoft.Json.dll",
34-
"System.IO.Hashing.dll",
35-
"ZstdSharp.dll",
3628
}
3729
}
3830

@@ -129,25 +121,22 @@ def reporthook(block_num: int, block_size: int, total_size: int) -> None:
129121
else:
130122
dialog_message = "Extracting/Updating LSLib files..."
131123
win_title = "Extracting LSLib"
132-
x_progress = self._utils.create_progress_window(
133-
win_title, len(self._needed_lslib_files), msg=dialog_message
134-
)
135124
with zipfile.ZipFile(zip_path, "r") as zip_ref:
136-
for file in self._needed_lslib_files:
137-
if downloaded or not file.exists():
138-
shutil.move(
139-
zip_ref.extract(
140-
f"Packed/Tools/{file.name}", self._utils.tools_dir
141-
),
142-
file,
143-
)
125+
names = list(filter(lambda name: name.startswith("Packed/Tools"), zip_ref.namelist()))
126+
qDebug(f"found files: {','.join(names)}")
127+
x_progress = self._utils.create_progress_window(
128+
win_title, len(names), msg=dialog_message
129+
)
130+
for file in names:
131+
shutil.move(zip_ref.extract(file, self._utils.tools_dir), self._utils.tools_dir)
144132
x_progress.setValue(x_progress.value() + 1)
145133
QApplication.processEvents()
146134
if x_progress.wasCanceled():
135+
x_progress.close()
147136
qWarning("processing canceled by user")
148137
return False
149-
x_progress.close()
150-
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
138+
x_progress.close()
139+
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
151140
except Exception as e:
152141
qDebug(f"Extraction failed: {e}")
153142
err = QMessageBox(self._utils.main_window)

0 commit comments

Comments
 (0)