diff --git a/remote/version.txt b/remote/version.txt index c0943d3..7208c21 100644 --- a/remote/version.txt +++ b/remote/version.txt @@ -1 +1 @@ -2.3 \ No newline at end of file +2.4 \ No newline at end of file diff --git a/src/aoe2de_patcher.py b/src/aoe2de_patcher.py index f61ce57..ebc40b4 100644 --- a/src/aoe2de_patcher.py +++ b/src/aoe2de_patcher.py @@ -17,7 +17,7 @@ def __init__(self): self.logic = Logic() self.patch_list = list(reversed(self.logic.get_patch_list())) - self.version = 2.3 + self.version = 2.4 # Set up GUI self.window = tk.Tk() diff --git a/src/logic.py b/src/logic.py index cbc5add..fe0c128 100644 --- a/src/logic.py +++ b/src/logic.py @@ -227,26 +227,31 @@ def _download_patch(self, username: str, password: str, target_version: int): # Iterate depots of current and target patch together for current_depot, target_depot in zip(current_patch["depots"], target_patch["depots"]): - depot_id = current_depot["depot_id"] - current_manifest_id = current_depot["manifest_id"] - target_manifest_id = target_depot["manifest_id"] - - changes = self._get_filelist(username, password, depot_id, current_manifest_id, target_manifest_id) - - # Files have changed, store changes to temp file and add to update list - if not changes is None: - # Create temp file - tmp = tempfile.NamedTemporaryFile(mode="w", delete=False) - - # Store file name for deletion later on - tmp_files.append(tmp.name) - - # Write content to file - tmp.write("\n".join(changes)) - tmp.close() - - # Add update element to list - update_list.append({ 'depot_id': depot_id, 'manifest_id': target_manifest_id, 'filelist': tmp.name }) + # Check if depot id changes (VCRedist for example does change sometimes) + # (Temporary?) solution just skip non-matching depot since old depots are no longer available and hope it still works + if current_depot["depot_id"] == target_depot["depot_id"]: + depot_id = current_depot["depot_id"] + current_manifest_id = current_depot["manifest_id"] + target_manifest_id = target_depot["manifest_id"] + + changes = self._get_filelist(username, password, depot_id, current_manifest_id, target_manifest_id) + + # Files have changed, store changes to temp file and add to update list + if not changes is None: + # Create temp file + tmp = tempfile.NamedTemporaryFile(mode="w", delete=False) + + # Store file name for deletion later on + tmp_files.append(tmp.name) + + # Write content to file + tmp.write("\n".join(changes)) + tmp.close() + + # Add update element to list + update_list.append({ 'depot_id': depot_id, 'manifest_id': target_manifest_id, 'filelist': tmp.name }) + else: + print(f"Depot ID not matching, discarding pair ({current_depot['depot_id']}, {target_depot['depot_id']})") print("Downloading files") @@ -436,11 +441,14 @@ def _get_filelist(self, username: str, password: str, depot_id: int, current_man """Get a list of all files that have been removed or modified between the current and target version. Args: - selected_version (int): The selected version - relevant_depots (list): A list of depots that should be checked + username (str): The username + password (str): The password + depot_id (int): The selected depot + current_manifest_id (int): The current manifest id for the depot + target_manifest_id (id): The target manifest id for the depot Returns: - list: A list of tuples (depot id, filelist, manifest id) or None + list: A list of changed filenames """ # Only need to check for changes if manifest changed if current_manifest_id == target_manifest_id: @@ -482,6 +490,26 @@ def _get_filelist(self, username: str, password: str, depot_id: int, current_man return changes + def _get_filelist_current(self, username: str, password: str, depot_id: int, manifest_id: int): + """Get a list of all files current files of a depot. + + Args: + username (str): The username + password (str): The password + depot_id (int): The selected depot + manifest_id (int): The current manifest id for the depot + + Returns: + list: A list of current filesnames for the depot + """ + # Download manifests + self._download_manifest(username, password, depot_id, manifest_id) + + # Read manifest files + current_manifest = self._read_manifest(self.manifest_dir / f"manifest_{depot_id}_{manifest_id}.txt") + + return current_manifest.files + def _read_manifest(self, file: pathlib.Path): """Parse a given manifest file and return a manifest object