From 175168adcb58996ec8b358d77b8b38df30f7d5fe Mon Sep 17 00:00:00 2001 From: derrod Date: Sat, 17 Jun 2023 20:24:40 +0200 Subject: [PATCH] [utils] Fix cloud save pattern matching to align with EGL Match the pattern as a suffix, this is valid to catch all files with that exact name in a directory. --- legendary/utils/savegame_helper.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/legendary/utils/savegame_helper.py b/legendary/utils/savegame_helper.py index aadba25..04c7e69 100644 --- a/legendary/utils/savegame_helper.py +++ b/legendary/utils/savegame_helper.py @@ -22,11 +22,14 @@ def _filename_matches(filename, patterns): """ for pattern in patterns: - if pattern.endswith('/'): - # pat is a directory, check if path starts with it - if filename.startswith(pattern): - return True - elif fnmatch(filename, pattern): + # Pattern is a directory, just check if path starts with it + if pattern.endswith('/') and filename.startswith(pattern): + return True + # Check if pattern is a suffix of filename + if filename.endswith(pattern): + return True + # Check if pattern with wildcards ('*') matches + if fnmatch(filename, pattern): return True return False