Skip to content

Commit

Permalink
umu_bspatch: refactor task submission
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Jan 25, 2025
1 parent e6d2323 commit c82c491
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions umu/umu_bspatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def __init__( # noqa: D107
self._arc_manifest: list[ManifestEntry] = self._arc_contents["manifest"]
self._compat_tool = compat_tool
self._thread_pool = thread_pool
self._futures: list[Future] = []
# Collection where each task creates a new file within an existing compatibility tool
self._add: list[Future] = []
# Collection where each task updates an existing file
self._update: list[Future] = []
# Collection where each task verifies an existing file
self._verify: list[Future] = []

def add_binaries(self) -> None:
"""Add binaries within a compatibility tool.
Expand All @@ -131,7 +136,7 @@ def add_binaries(self) -> None:
build_file: Path = self._compat_tool.joinpath(item["name"])
if item["type"] == FileType.File.value:
# Decompress the zstd data and write the file
self._futures.append(
self._add.append(
self._thread_pool.submit(self._write_proton_file, build_file, item)
)
continue
Expand Down Expand Up @@ -160,7 +165,7 @@ def update_binaries(self) -> None:
build_file: Path = self._compat_tool.joinpath(item["name"])
if item["type"] == FileType.File.value:
# For files, apply a binary patch
self._futures.append(
self._update.append(
self._thread_pool.submit(self._patch_proton_file, build_file, item)
)
continue
Expand Down Expand Up @@ -209,13 +214,13 @@ def delete_binaries(self) -> None:
def verify_integrity(self) -> None:
"""Verify the expected mode, size, file and digest of the compatibility tool."""
for item in self._arc_manifest:
self._futures.append(
self._verify.append(
self._thread_pool.submit(self._check_binaries, self._compat_tool, item)
)

def result(self) -> list[Future]:
"""Return the currently submitted tasks."""
return self._futures
def result(self) -> tuple[list[Future], list[Future], list[Future]]:
"""Return all the currently submitted tasks."""
return (self._verify, self._add, self._update)

def _check_binaries(self, proton: Path, item: ManifestEntry) -> ManifestEntry:
rpath: Path = proton.joinpath(item["name"])
Expand Down

0 comments on commit c82c491

Please sign in to comment.